C++ Class Construct  «Prev  Next»

Using external C++ member functions - Exercise

Using external C++ member functions

Objective: Rewrite the Person class so it uses an external member function to print out its member data.

Instructions

Use the person class you created in the previous exercise and write the print member function as an external member function. To define a member function outside the class, the scope resolution operator is used. Paste the class below and click the Submit button when you are ready to submit this exercise.
Note: Definitions of member functions outside of their class belong in the source file for the class, not in the class's header file. Otherwise, the member function ends up being defined more than once when the header file is included multiple times. The exceptions to this are definitions of member functions preceded by the keyword inline, and those implementing template classes, since these go in header files.