Answer to Question #187434 in C++ for Mani

Question #187434

Base class: College

    variable: cname, city

    Funciton: get(), display()

Derived class inherited from college: Department

    variable: dname

    function :get(), display()

Base class: Education

    variable: Degree, University

    function : get(), display()

Derived class inherited from college and education: Teacher

   variable: Teacher

    tname function : get(), display()

Write a C++ program to display the details of faculty members in an institution.


1
Expert's answer
2021-04-30T17:25:04-0400
#include <iostream>
using namespace std;
class College{
    protected:
        string cname, city;
    public:
        College(){}
        virtual void get(){}
        virtual void display(){}
};
class Department: public College{
    protected:
        string dname;
    public:
        Department(){}
        void get(){}
        void display(){}
};
class Education{
    protected:
        string degree, university;
    public:
        void get(){}
        void display(){}
};
class Teacher: public College, public Education{
    string tname;
    public:
        Teacher(){}
        void get(){
            cout<<"Enter teacher name: ";
            cin>>tname;
            cout<<"Enter teacher degree: ";
            cin>>degree;
            cout<<"Enter university: ";
            cin>>university;
            cout<<"Enter college: ";
            cin>>cname;
            cout<<"Enter city: ";
            cin>>city;
        }
        void display(){
            cout<<"Teacher name: "<<tname<<endl;
            cout<<"Degree: "<<degree<<endl;
            cout<<"University: "<<university<<endl;
            cout<<"College: "<<cname<<endl;
            cout<<"City: "<<city<<endl;
        }
};
int main(){
    Teacher teacher;
    teacher.get();
    cout<<"\nTeacher details are; \n";
    teacher.display();
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS