0% found this document useful (0 votes)
28 views3 pages

Course Management

The document defines C++ classes for representing people and academic entities in an educational system. The Person class serves as a base class for Faculty and Student. Course is a base class for Degree, which is then extended by Bsc. The main function demonstrates creating instances of these classes and calling their display methods to output name, age, department, major, credits, level, and specialization as appropriate.

Uploaded by

Vishnupriya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views3 pages

Course Management

The document defines C++ classes for representing people and academic entities in an educational system. The Person class serves as a base class for Faculty and Student. Course is a base class for Degree, which is then extended by Bsc. The main function demonstrates creating instances of these classes and calling their display methods to output name, age, department, major, credits, level, and specialization as appropriate.

Uploaded by

Vishnupriya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

#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