August 2001
Beginner
482 pages
10h 52m
English
Other keywords are used in the declaration of a class. Two of the most important are public and private. |
All member data and functions are private by default. Private members can be accessed only within methods of the class itself. Public members can be accessed through any object of the class. This distinction is important, but can be confusing. To make it a bit clearer, consider an example from earlier in this chapter:
class Cat
{
unsigned int itsAge;
unsigned int itsWeight;
Meow();
};
In this declaration, itsAge, itsWeight, and Meow() are all private, because all members of a class are private by default. This means ...
Read now
Unlock full access