Write a program to illustrate array of object
Array Of Object
PROGRAM:
#include<iostream> using namespace std; class employee{ int age; char name[10]; public: void getdata(){ cout<<"\nEnter name :"; cin>>name; cout<<"\nAge :"; cin>>age; } void print(){ cout<<"\nEntered name :"<<name<<"\tAge: "<<age; } }; int main(){ employee Manager[3],Worker[5]; int i; for(i=0;i<3;i++){ Manager[i].getdata(); Manager[i].print(); } for(i=0;i<5;i++){ Worker[i].getdata(); Worker[i].print(); } return 0; }
Comments
Post a Comment