Untitled

 avatar
unknown
plain_text
5 months ago
2.7 kB
35
Indexable
#include <iostream>
using namespace std;

class father {
public:
    char f_name[50];
    int f_age;
    char f_complexion[10];

    void get_data_father() {
        cout << "\n Enter father name: ";
        cin >> f_name;
        cout << "\n Enter father age: ";
        cin >> f_age;
        cout << "\n Enter complexion: ";
        cin >> f_complexion;
    }

    void put_data_father() {
        cout << "\n Father name: " << f_name;
        cout << "\n Father age: " << f_age;
        cout << "\n Complexion: " << f_complexion;
    }
};

class mother {
public:
    char m_name[50];
    int m_age;
    char m_complexion[10];

    void get_data_mother() {
        cout << "\n Enter mother name: ";
        cin >> m_name;
        cout << "\n Enter age: ";
        cin >> m_age;
        cout << "\n Enter complexion: ";
        cin >> m_complexion;
    }

    void put_data_mother() {
        cout << "\n Mother name: " << m_name;
        cout << "\n Mother age: " << m_age;
        cout << "\n Complexion: " << m_complexion;
    }
};

class child : public father, public mother {
public:
    float ch_height;

    void get_data_child() {
        cout << "\n Enter child name: ";
        cin >> f_name;
        cout << "\n Enter age: ";
        cin >> m_age;
        cout << "\n Enter complexion: ";
        cin >> m_complexion;
        cout << "\n Enter child height: ";
        cin >> ch_height;
    }

    void put_data_child() {
        cout << "\n Child name: " << f_name;
        cout << "\n Child age: " << m_age;
        cout << "\n Child complexion: " << m_complexion;
        cout << "\n Child height: " << ch_height;
    }
};

class grand_child : public father {
public:
    float gch_weight;

    void get_data_gchild() {
        cout << "\n Enter grandchild name: ";
        cin >> f_name;
        cout << "\n Enter age: ";
        cin >> f_age;
        cout << "\n Enter complexion: ";
        cin >> f_complexion;
        cout << "\n Enter child weight: ";
        cin >> gch_weight;
    }

    void put_data_gchild() {
        cout << "\n Grandchild name: " << f_name;
        cout << "\n Grandchild age: " << f_age;
        cout << "\n Grandchild complexion: " << f_complexion;
        cout << "\n Grandchild weight: " << gch_weight;
    }
};

int main() {
    father fobj;
    mother mobj;
    child chobj;
    grand_child gchobj;

    fobj.get_data_father();
    mobj.get_data_mother();
    chobj.get_data_child();
    gchobj.get_data_gchild();

    fobj.put_data_father();
    mobj.put_data_mother();
    chobj.put_data_child();
    gchobj.put_data_gchild();

    return 0;
}
Editor is loading...
Leave a Comment