August 2012
Intermediate to advanced
976 pages
30h 17m
English
At this point, we have defined an interface for our class; but nothing forces users to use that interface. Our class is not yet encapsulated—users can reach inside a Sales_data object and meddle with its implementation. In C++ we use access specifiers to enforce encapsulation:
• Members defined after a public specifier are accessible to all parts of the program. The public members define the interface to the class.
• Members defined after a private specifier are accessible to the member functions of the class but are not accessible to code that uses the class. The private sections encapsulate (i.e., hide) ...
Read now
Unlock full access