Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 9. C++ Class as a Unit of Modula... > Implementing Member Functions Outsid...

Implementing Member Functions Outside of Class

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


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial