Page 177 - C++
P. 177

public:

                       employee();

                       void getdata();

                       void show();

        };

        Write a code in C++ to publicly derive another class department with the following additional public members:

        Data Members

        deptcode string data type

        deptname string data type

        Member functions:

        Constructor of class department

        Function Entry() to input values of data members
        Function Display() to display values


        Ans.
        class department : public employee


        {
        public:

               char deptcode[10];

               char deptname[10];

               void entry()

               {

                       cin>>deptcode;

                       cin>>deptname;

               }

               void show()

               {

                       cout<<deptcode;

                       cout<<deptname;

               }

        };
   172   173   174   175   176   177   178   179   180   181   182