Saturday, September 27, 2014

Write three classes with the derived classes inheriting functionality of base class person (should have a member function that asks to enter name and age) and with added unique features of students and employee.

#include
#include
class base
{
            protected:
            char name[20];
            int age;
            public:
            void getdata()
            {
                        cout<<"Enter name:";
                        cin>>name;
                        cout<<"Enter age:";
                        cin>>age;
            }
};
class student:public base
{
            int marks;
            public:
            void get()
            {
                        base::getdata();
                        cout<<"Enter marks of student:";
                        cin>>marks;
            }
            void show()
            {
                        cout<
            }
};
class employee:public base
{
            long int salary;
            public:
            void get()
            {
                        base::getdata();
                        cout<<"Enter salary of employee:";
                        cin>>salary;
            }
            void show()
            {
                        cout<
            }
};
void main()
{
            clrscr();
            student s;
            s.get();
            s.show();
            employee e;
            e.get();
            e.show();
            getch();

}

No comments:

Post a Comment