Define function outside the class

               Program to enter & display detail of 5 employ




#include<iosteram.h>
#include<conio.h>
class employ
{
char name[20];
int age;
public;
void getdata();
void putdata();
};
void employ::getdata()
{
cout<<"Enter employee name";
cin>>name;
cout<<"Enter employee age";

cin>>age;
}
void employ::putdata()
{
cout<<"\n"<<name<<"\t"<<age;
}
void main()
{
clrscr();
employ b1[10];
int i;
for(i=0;i<5;i++)
{
b1[i].getdata();
}
cout<<"Employee details are: \n";
cout<<"name \t age";
for(i=0;i<5;i++)
{
b1[i].putdata();
}
getch();



Note:- 

If you use  turboc++  then you use this code,
if you use  dev c++  the you use that header file and copy whole code

#include<iostream>
#include<conio.h>
using namespace std;
class employ..........
and copy whole code which is written above the note.



Output of enter & display detail of 5 employ :-


Enter employee name: Aditya
Enter employee age: 18
Enter employee name: Ashutosh
Enter employee age: 18
Enter employee name: Ankit
Enter employee age: 19
Enter employee name: Amit
Enter employee age: 19
Enter employee name: Arpit
Enter employee age: 20

Employ details are: 
name                    age
Aditya                  18
Ashutosh              18
Ankit                    19
Amit                     19
Arpit                     20



Comments

Popular posts from this blog

Addition of two matrix using Array

Multiplication of matrix using Array

Addition of two no. using Class