November 2001
Beginner
1128 pages
29h 12m
English
C++ lets you define pointers to members of a class. These pointers involve special notations to declare them and to dereference them. To see what's involved, let's start with a sample class:
class Example
{
private:
int feet;
int inches;
public:
Example();
Example(int ft);
~Example();
void show_in() const;
void show_ft() const;
void use_ptr() const;
} ;
Consider the inches member. Without a specific object, inches is a label. That is, the class defines inches as a member identifier, but you need an object before you actually have memory allocated:
Example ob; // now ob.inches exists
Thus, you specify an actual memory location by using the identifier inches in conjunction with a specific object. (In a member ...