// dynamic 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() { int n; cout<<"Enter object size :"; cin>>n; abc z[n]; int i; for(i=0; i<n; i++) { z[i].set(); } cout<<"\n out put \n"; for(i=0; i<n; i++) { z[i].get(); } }
Enter object size :3 Enter your roll no :1 Enter your name :biku Enter your roll no :2 Enter your name :sunil Enter your roll no :3 Enter your name :montu out put your name is :biku your roll is 1 your name is :sunil your roll is 2 your name is :montu your roll is 3
0 Comments