August 2012
Intermediate to advanced
976 pages
30h 17m
English
As with any pointer, we declare a pointer to member using a * to indicate that the name we’re declaring is a pointer. Unlike ordinary pointers, a pointer to member also incorporates the class that contains the member. Hence, we must precede the * with classname:: to indicate that the pointer we are defining can point to a member of classname. For example:
// pdata can point to a string member of a const (or non const) Screen objectconst string Screen::*pdata;
declares that pdata is a “pointer to a member of class Screen that has type const string.” The data members in a const object are themselves const. By making our pointer a pointer to const string member, we say that we can use pdata to point to a member of ...
Read now
Unlock full access