HOME

Friday, September 4, 2015

TAKE INPUT AND DISPLAY DETAIL OF EMPLOY USING CLASS IN C++

#include<iostream>
using namespace std;
class employ
{
    char name[20];
    int id;
    double salary;
public:
    void getdata();
    void display();
};
void employ :: getdata()
{
    cout<<"Enter the name of the employ"<<endl;
    cin>>name;
    cout<<"Enter the ID of employ"<<endl;
    cin>>id;
    cout<<"Enter the salary of the employ"<<endl;
    cin>>salary;
}
void employ :: display()
{
    cout<<name<<"\t"<<id<<"\t"<<salary<<endl;
}
int main()
{
    employ a,b;
    a.getdata();
    b.getdata();
    cout<<"\nNAME\t"<<"ID\t"<<"SALARY"<<endl;
    a.display();
    b.display();
return 0;
}

No comments:

Post a Comment