Ad Code

Responsive Advertisement

array of object





// array of object
#include<iostream>
using namespace std;

class abc
{	
	int roll;
	char name[10];
	
	public:
		void set()
		{
			cout<<"Enter your roll no :";
			cin>>roll;
			cout<<"Enter your name  :";
			cin>>name;
		}
		void get()
		{
			cout<<"your name is :"<<name<<"\n";
			cout<<"your roll is "<<roll<<"\n";
		}
};

int main()
{
	abc z[10];
	int i;
	
	for(i=0; i<3; i++)	
	{
		z[i].set();
	}	
	cout<<"\n out put \n";	
	for(i=0; i<3; i++)
	{
		z[i].get();
	}
}
Enter your roll no : 109
Enter your name : biku

Enter your roll no: 110
Enter your name : montu

Enter your roll no : 111
Enter your name : sunil

your name is : vibhu
Your roll is 109

your name is : biku
your roll no is :110

your name is sunil
your roll no us : 111

Post a Comment

0 Comments