Answer to Question #180623 in C++ for Dharmendra Tripathi

Question #180623

Define a class Employee with data member as name,emp_id,age. Wrie a programm to write the data of three employee's using class object. Read the records of employee and print them to console


1
Expert's answer
2021-04-12T10:52:14-0400
#include<iostream>
#include <string>

using namespace std;
class Employee {
private:    
      string name;
    int emp_id;
    int age;
 
public :
     //  user input
    Employee() {
    cout << "Enter employee information :"<<endl;
    cout << "Name: ";
    cin >> name;
    cout << "ID: ";
    cin >> emp_id;
    cout << "Age: ";
    cin >> age;
    cout<<endl;
}
    void display();
};



void Employee::display() {
    cout <<"===============================" << endl
         <<"Employee name " << name <<endl
         <<"Employee ID   "<< emp_id << endl
         <<"Age   "<<age << endl<<endl;
}
int main() {
// Write the data of three employee's using class object
    Employee EmpA;
    Employee EmpB;
    Employee EmpC;
    
// Read the records of employee and print them to console    
    EmpA.display();
    EmpB.display();
    EmpC.display();        

    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

Assignment Expert
14.04.21, 14:35

Dear Prashant pal, sure

Prashant pal
14.04.21, 09:37

Is it right answer

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS