Answer to Question #333184 in C++ for Rishab

Question #333184

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


1
Expert's answer
2022-04-25T04:43:06-0400


#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS