Structure of the Problem Requirements
We used array because we can't have too much variables names for integers(reduce the readability of code if declare variable for each integer ), Secondly we can put values sequentially in array. Now consider if we need to create hundred object then ?. To handle this situation we need to create array of object. Just like arrays , array of object also used to simplify the large problem.
Source Code
#include<iostream>
using namespace std;
class LEP_Member
{
public:
char names [25];
int batch_no;
void Emp_names ()
{
cout<<" \n Enter the Name of Employe \n ";
cin>>names;
cout<<" \n Enter the Batch No \n ";
cin>>batch_no;
}
void display ()
{
cout<<" \n Employe Name : "<<names;
cout<<" \n Employe Batch : "<<batch_no;
}
};
int main ()
{
cout<<" \t \t \t Array of Object \n \n ";
LEP_Member LEP [5];
for ( int i = 0; i < 5;i++ )
{
LEP[i].Emp_names();
}
for ( int i = 0; i < 5;i++)
{
LEP[i]. display();
}
}
Output of the Program
0 comments:
Post a Comment