Saturday, 11 January 2014

A program in C++ using classes to enter the data of an employee and display it.

#include<iostream.h>
#include<conio.h>
class Emp
{public:char name[10];
            int age;
            int salary;
public:void init();
       void display();
};
void main()
{clrscr();
 Emp obj;
 obj.init();
 obj.display();
 getch();
}
void Emp::init()
{Emp obj;
 cout<<"\n ENTER THE NAME ==> \n";
 cin>>obj.name;
 cout<<"\n ENTER THE AGE ==> \n";
 cin>>obj.age;
 cout<<"\n ENTER THE SALARY ==> \n";
 cin>>obj.salary;
}
void Emp::display()
{Emp obj;
 cout<<"\n EMPLOYEE'S NAME \n"<<obj.name;
 cout<<"\n EMPLOYEE'S AGE \n"<<obj.age;
 cout<<"\n EMPLOYEE'S SALARY \n"<<obj.salary;
}


No comments:

Post a Comment