/*Array of Objects */
#include<iostream>
using namespace std;
class Sample
{
int a;
public:
void accept();
void display();
};
void Sample:: accept()
{
cout<<"\n\n Enter any number: ";
cin>>a;
}
void Sample:: display()
{
cout<<"\n\n A: "<<a;
}
int main()
{
Sample s[5];
cout<<"\n\n Enter 5 values: ";
for(int i=0;i<5;i++)
s[i].accept();
cout<<"\n\n Entered values : ";
for(int i=0;i<5;i++)
s[i].display();
return 0;
}
#include<iostream>
using namespace std;
class Sample
{
int a;
public:
void accept();
void display();
};
void Sample:: accept()
{
cout<<"\n\n Enter any number: ";
cin>>a;
}
void Sample:: display()
{
cout<<"\n\n A: "<<a;
}
int main()
{
Sample s[5];
cout<<"\n\n Enter 5 values: ";
for(int i=0;i<5;i++)
s[i].accept();
cout<<"\n\n Entered values : ";
for(int i=0;i<5;i++)
s[i].display();
return 0;
}