Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Notice that these member functions are correct only when they are implemented inside the class scope, that is, within the class braces, as in Listing 9.2. If they are implemented outside the class scope, different syntax should be used. This syntax is used when the relationship between member functions and data members of the class is established using function prototypes within the class declaration (specification) instead of the complete implementations, as in Listing 9.2.
struct Cylinder { // start of class scope
double radius, height; // data fields to access
void setCylinder(double r, double h); // set Cylinder fields
double getVolume(); // compute volume
void scaleCylinder(double factor); // scale dimensions
void printCylinder(); // print object state
} ; // end of class scope