OOPortal
SiteMap
Building C++ Classes
Programming C++
Constructor Functions
«Prev
Next»
Building C++ Classes
OOP Encapsulation
OOP Encapsulation - Quiz
Black Box Principle
Class vs. Struct
C++ Class Constructs
Scope Resolution Operator
Unary Form Scope Resolution
Binary Scope Resolution
Orthogonal Class Design
Overloading Member Functions
External Member Functions
Constructor Functions
Constructor Initializer List
Cplus Constructor - Quiz
Dynamic Stack
Default Copy Constructors
Adding a constructor and initializers - Exercise
Objective:
Add a constructor, an initializer list, and a destructor to the
person class
you created in an earlier exercise.
Instructions
The constructor and initializer list should have arguments for all the data members you created in your
person class
. You also might want to consider using the
string
library for any useful
string
functions you need.
Although we only discussed destructors briefly in this module, you should be able to add a very basic destructor to this
class
.
If you are having trouble creating a destructor, you may want to review the lessons entitled
What is a destructor?
and
Constructor and destructor example
.
Paste the source code of your
class
below and click the
Submit
button when you are ready to submit this exercise.
Submit