154k views
1 vote
Instructor i1("Prof. S. Trowbridge", "Engineering Technology"); Instructor i2("Prof. A. Guozhen", "Engineering Technology"); Instructor i3("Prof. J. Sun", "Engineering Technology");

1 Answer

5 votes

Answer:

#include<iostream>

using namespace std;

class Instructor

{

public :

string pname,course_name;

Instructor(string name,string course) //constructor to initialise member variables

{

pname=name;

course_name=course;

}

string get_pname() //method to return professor's name

{

return pname;

}

string get_cname() //method to return course name

{

return course_name;

}

};

int main()

{

Instructor i("Rajpal","MCA"); //constructor is called

cout<<"Professor's name is "<<i.get_pname();

cout<<"\\Professor teaches "<<i.get_cname();

return 0;

}

OUTPUT :

Professor's name is Rajpal

Professor teaches MCA

Step-by-step explanation:

As nothing is mentioned in question. A c++ code implementation of statements is created.Instructor class has a constructor which takes 2 values. Statements mentioned in question can easily be run by the above program.

User Designil
by
6.4k points