Professional Documents
Culture Documents
System
CODE:
#include <iostream>
#include <string>
using namespace std;
class Car{
public:
string make;
string model;
int year;
string color;
Car():make(""),model(""),year(0),color(""){}
Car(string _make, string _model,int _year,string _color):
make(_make),model(_model),year(_year),color(_color){}
void displayInfo(){
cout<<"The make of the car is: "<<make<<"\nThe model of the Car is:
"<<model<<"\nThe year of the Car is: "<<year<<"\nThe color of the Car is:
"<<color<<"\n|*****************************************|\n"<<endl;
}
};
class Aircraft{
public:
string manufacturer;
string model;
string fuelType;
Aircraft():manufacturer(""),model(""),fuelType(""){}
Aircraft(string _manufacturer, string _model, string
_fuelType):manufacturer(_manufacturer),model(_model),fuelType(_fuelType){}
void fly(){
cout<<"Flying the Aircraft"<<endl;
}
void displayInfo(){
cout<<"The manufacturer of the Aircarft is: "<<manufacturer<<"\nThe model
of the Aircraft is: "<<model<<"\nThe FuelType of the Car is:
"<<fuelType<<"\n|*****************************************|\n"<<endl;
}
};
void activateFlightMode() {
cout << "Flight mode activated for the flying car." << endl;
}
};
int main(){
FlyingCar myFlyingCar("Toyota", "SkyGlider", 2023, "Silver", "Boeing",
"SkyMaster", "Diesel");
myFlyingCar.drive();
myFlyingCar.Car::displayInfo();
myFlyingCar.fly();
myFlyingCar.Aircraft::displayInfo();
myFlyingCar.activateFlightMode();
return 0;
}
OUTPUT:
Task 2:
Consider an employee management system where:
Employee:
Represents the base class containing common properties and methods for all employees.
Methods might include work(), calculateSalary(), etc.
Manager:
Inherits from Employee.
Contains managerial-specific functionalities and overrides some methods (e.g., work() might
include
additional supervisory tasks).
Developer:
Also inherits from Employee.
Contains developer-specific functionalities and overrides some methods (e.g., work() might
involve coding
tasks).
TeamLead:
Inherits from both Manager and Developer.
Represents a role that requires managerial responsibilities from Manager and technical
expertise from
Developer.
CODE:
#include <iostream>
#include <string>
using namespace std;
class Employee{
public:
string name;
int employeeId;
double baseSalary;
void manageTeam() {
cout << "Manager is managing the team." << endl;
}
};
void writeCode() {
cout << "Developer is writing code." << endl;
}
double calculateSalary(){
return Manager::baseSalary;
}
};
int main() {
Manager manager("Ali", 101, 80000.0);
Developer developer("Wozniak", 201, 70000.0);
TeamLead teamLead("Arham TeamLead", 301, 90000.0);
manager.work();
cout << "Manager Salary: $" << manager.calculateSalary() <<endl;
cout << endl;
developer.work();
cout << "Developer Salary: $" << developer.calculateSalary() <<endl;
cout <<endl;
teamLead.work();
cout << "TeamLead Salary: $" << teamLead.calculateSalary() <<endl;
return 0;
}
OUTPUT: