Sunday 5 April 2020

Program: Write a Program which creates & uses array of object of a class.( for eg. implementing the list of Managers of a Company having details such as Name, Age, etc..).

#include<iostream.h>
#include<conio.h>
class employee

char name [30]; 
float age;
public: 
void getdata(void); 
void putdata(void);
};
void employee :: getdata(void)

cout<<"Enter Name"; 
cin>>name; 
cout<<"Enter Age"; 
cin>>age;
}
void employee :: putdata(void)

cout<<"Name:"<<name<<"\n"; 
cout<<"Age:   "<<age<<"\n";
}

int main()
{     
employee manager[3]; 
for(int i=0; i<3; i++) 

cout<<"\n Details of manager"<<i+1<<"\n"; 
manager[i].getdata(); 

cout<<"\n"; 
for(i=0; i<size; i++) 

cout<<"\n Manager"<<i+1<<"\n"; 
manager[i].putdata(); 
}   
return 0;
}

No comments:

Post a Comment