Home > Article > Backend Development > How Does "= delete" Prevent Function or Constructor Usage in C ?
Deletion of Functions in C with = delete
C introduces the "= delete" syntax, which allows developers to explicitly prohibit certain functions or constructors from being used. This is achieved by appending "= delete" to the function or constructor declaration within a class.
Consider the following example:
class my_class { ... my_class(my_class const &) = delete; ... };
Meaning of = delete
In the context of function or constructor declarations, "= delete" serves the following purpose:
Additional Modifiers
Apart from "= delete," there are no other modifiers in C that serve the same purpose of explicitly preventing function or constructor usage. However, it's worth noting that "= 0" (the default constructor definition in C ) and "= default" (introduced in C 11) can be used to provide default implementations for constructors and member functions if not explicitly defined in the class.
The above is the detailed content of How Does "= delete" Prevent Function or Constructor Usage in C ?. For more information, please follow other related articles on the PHP Chinese website!