Challenge 3: Implement a Father Class

In this challenge, we'll implement a base class father and derived classes, son and daughter.

Problem Statement

Implement a code which have:

  • A parent class named Father.
    • Inside it define:
      • eye_color
      • hair_color
      • void Father_traits() function:
        • It prints the eye_color and hair_color of the called object
  • Then, there are two derived classes
    • Son class
      • has a private member name
      • has a function named Son_traits() which prints traits of the Son
    • Daughter class
      • has a private member name
      • has a function named Daughter_traits() which prints traits of the Daughter
  • The derived classes should
    • call the method of the Father class which prints the eye_color and the hair_color and for Son and Daughter classes prints the name of a respective object.

Input

  • In Sonclass, eye_color is set to Brown and the hair_color is set to Black and name is set to Ralph in parametrized constructor of Son object

  • In Daughterclass, eye_color is set to Green and the hair_color is set to Golden and name is set to Rapunzel in parametrized constructor of Daughter object

  • Now, print Son_traits and Daughter_traits from their respective objects

Here’s a sample result which you should get.

Sample Input

Daughter obj("Rapunzel","Green","Golden");
obj.Daughter_traits();

Son Obj("Ralph","Brown","Black");
Obj.Son_traits();

Expected Output