Create a program in C++ that will declare two classes. The "Student" class will inherit the class "Person". Below are the following attributes of each class.
Class name: Person
Attribute: Age is in datatype integer
Class name: Student
Attribute: Department is in datatype string
Value of variable Age is 25. Value of variable Department is IT_Department
#include <iostream>
#include <string>
using namespace std;
class Person {
private:
int Age;
public:
Person(int Age1 = 25):
Age(Age1) {}
};
class Student : public Person {
private:
string Department;
public:
Student(string Department1 = "IT_Department", int Age1 = 25):
Person(Age1), Department(Department1) {}
};
Comments
Leave a comment