#1. About Inheritance, Constructors, and Function Overriding Write a program tha
ID: 649764 • Letter: #
Question
#1. About Inheritance, Constructors, and Function Overriding Write a program that contains the following parts. Write each class interface and implementation, in a different .h and .cpp file, respectively. a) Create a class called Student that has a name (string) and ID (int) as member variables. b) Create a derived class called ComputerSystemsStudent from Student class. ComputerSystemsStudent has also a track (string) as member variable. A track can be values such a Programming, Web Design, Networking, etc. C) Write a constructor with all default parameters for Student and ComputerSystensStudent classes. d) Write printlnfo() function for Student and ConputerSystemsStudent classes. ?? For full credit, ConputerSystemsStudent class must overridde the printlnfo of the Student class. e) Create a test program that includes one to two objects Student ComputerSystemsStudent classes and write test code print information about each object. Save your .h and .cpp files in a folder called ab7-l-yourName and zip the entire folder and upload it to Angel drop box. --> note that you need submit a total of five files!Explanation / Answer
include <iostream>
#include<string>
using namespace std;
class Student
{
protected:
int id;
string name;
public:
Student()
{
id=78;
name="shalini";
}
void printinfo()
{
cout<<"id"<<id<<endl;
cout<<"name"<<name<<endl;
//cout<<"track"<<track<<endln;
}
};
class ComputerSystemsStudent : public Student
{
private:
string track;
public:
ComputerSystemsStudent()
{
id =67;
name="monika";
track= "programming";
}
void printinfo()
{
cout<<"id"<<id<<endl;
cout<<"name"<<name<<endl;
cout<<"track"<<track<<endl;
}
};
int main() {
Student s;
s.printinfo();
ComputerSystemsStudent cstu;
cstu.printinfo();
// your code goes here
return 0;
}
output
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.