CPlusOOP
SiteMap
Building C++ Classes
Programming C++
C++ Class Construct
«Prev
Next»
Building C++ Classes
C++ Prerequisites
C++ Requirements
C++ Expectations
Different CPlus Compilers
OOP Encapsulation
OO Programming
Type Extensibility
Encapsulation Packing Data
C++ Class Concept
Object Class Concept
Declare Member Function
Using Member Function
Private Public Access
ADT Interface
Black Box Principle
Design C++ Class
OOP Conclusion
OOP Encapsulation - Quiz
C++ Class Constructs
Scope Resolution Operator
Unary Form Scope Resolution
Binary Scope Resolution
External Member Functions
Overloading Member Functions
Building Nested Classes
Static Class Members
CPlus this Pointer
Static const member functions
this pointer Implementation
Program Dissection
C++ Classes Conclusion
Constructor Functions
Variable Memory Allocation
Constructor Functions
Destructor Functions
Constructor Destructor
Initialization Constructor
Constructor Object Declaration
Default Constructor
Constructor Initializer List
Constructors As Conversions
C++ Constructor Function
Cplus Constructor - Quiz
Dynamic Stack
Dynamically sized Stack
Stack Constructors
Copy Constructors
Designing Copy Constructor
C++ Destructor Usage
Construct Dynamically Sized Stack
Dynamic Structures
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.