C++ Practical
Class Design Snippet-2
Question 2: Write a declaration for a class Person which has the following:
- data members name, phone
- set and get functions for every data member
- a display function
- a destructor
(i) For the Person class above, write each of the constructors, the assignment operator and the getName member functions. Use member initialization list as often as possible
(ii) Given the Person class above, write the declaration for the class Spouse that inherits from Person and does the following:
- has an extra data member spouseName
- redefines the display member function
(iii) For the Spouse class above, write each of the constructors and display member, functions. Use member initialization lists as often as possible.
Answer: