February 2005
Beginner to intermediate
272 pages
4h 53m
English
Access specifiers (public, protected, and private) can be used to express and enforce higher-level constraints on how a type may be used.
The most common of these techniques is to disallow copying of an object by declaring its copy operations to be private and not defining them:

It’s necessary to declare the copy constructor and copy assignment operator, since otherwise the compiler would declare them implicitly, as public inline members. By declaring them to be private, we forestall the compiler’s meddling and ensure that any use of the operations—whether explicit or implicit—will result in a compile-time error: ...
Read now
Unlock full access