Professional Documents
Culture Documents
Multi Level
Multi Level
#include <string>
// Base class
class Person {
private:
std::string name;
int age;
public:
void displayInfo() {
std::cout << "Name: " << name << ", Age: " << age << std::endl;
};
private:
std::string employeeId;
public:
// Constructor for Employee class, calling the base class constructor explicitly
void work() {
std::cout << "Employee with ID " << employeeId << " is working." << std::endl;
};
// Derived class (inherits from Employee)
private:
std::string department;
public:
// Constructor for Manager class, calling the base class constructor explicitly
void manageTeam() {
std::cout << "Manager of department " << department << " is managing the team." << std::endl;
};
int main() {
myManager.displayInfo();
myManager.work();
myManager.manageTeam();
return 0;