Create a class Employee having basic its details like name, age, Salary etc. Let there be a function show details which will print all the values for the data members. Further, inherit the same class to create two different classes Developer and Manager.
Implement the concept of runtime polymorphism by invoking the show details function
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
class Employee
{
string name ;
double sal;
int age;
public:
Employee()
{
}
Employee(string s,double ss,int ag)
{
this->name=s;
this->sal=ss;
this->age=ag;
}
void Print()
{
cout<<setw(20)<<name<<" |"<<sal<<"|"<<age<<endl;
}
};
int main() {
Employee emp("Marry",2500,18);
emp.Print();
return 0;
}
Comments
Leave a comment