Answer to Question #346617 in C++ for Amy

Question #346617

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

1
Expert's answer
2022-05-31T10:03:49-0400
#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) {}
};

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