You are on page 1of 3

#include <iostream>

#include <string>

class Person {
protected:
std::string name;
int age;

public:
Person(const std::string& name, int age) : name(name), age(age) {}

void display() {
std::cout << "Name: " << name << std::endl;
std::cout << "Age: " << age << std::endl;
}
};

class Faculty : public Person {


protected:
std::string department;

public:
Faculty(const std::string& name, int age, const std::string& department)
: Person(name, age), department(department) {}

void display() {
Person::display();
std::cout << "Department: " << department << std::endl;
}
};

class Student : public Person {


protected:
std::string major;

public:
Student(const std::string& name, int age, const std::string& major)
: Person(name, age), major(major) {}

void display() {
Person::display();
std::cout << "Major: " << major << std::endl;
}
};

class Course {
protected:
std::string name;
int credits;

public:
Course(const std::string& name, int credits) : name(name), credits(credits) {}

void display() {
std::cout << "Course Name: " << name << std::endl;
std::cout << "Credits: " << credits << std::endl;
}
};

class Degree : public Course {


protected:
std::string level;

public:
Degree(const std::string& name, int credits, const std::string& level)
: Course(name, credits), level(level) {}

void display() {
Course::display();
std::cout << "Level: " << level << std::endl;
}
};

class Bsc : public Degree {


protected:
std::string specialization;

public:
Bsc(const std::string& name, int credits, const std::string& level, const std::string&
specialization)
: Degree(name, credits, level), specialization(specialization) {}

void display() {
Degree::display();
std::cout << "Specialization: " << specialization << std::endl;
}
};

int main() {
Faculty faculty("John Doe", 40, "Computer Science");
faculty.display();

std::cout << std::endl;

Student student("Jane Smith", 20, "Computer Science");


student.display();
std::cout << std::endl;

Course course("Introduction to Programming", 3);


course.display();

std::cout << std::endl;

Degree degree("Bachelor of Science", 120, "Undergraduate");


degree.display();

std::cout << std::endl;

Bsc bsc("Computer Science", 120, "Undergraduate", "Software Engineering");


bsc.display();

return 0;

You might also like