#include<iostream.h>
#include<conio.h>
class person
{
char
name[50],sex[20],des[30];
int age;
public:
void getdata()
{
cout<<"enter
name,sex,designation,age\n";
cin>>name>>sex>>des>>age;
}
void putdata()
{
cout<<"name:"<<name<<"\n
sex:"<<sex<<"\n
designation:"<<des<<"\n age:"<<age;
}
};
void main()
{
person*ptr[20];
int n=0;
char choice;
clrscr();
do
{
ptr[n]=new
person;
ptr[n]->getdata();
n++;
cout<<"enter
another(y/n)\n";
cin>>choice;
}
while(choice=='y');
for(int
i=0;i<n;i++)
{
cout<<"\n\n
person number:"<<i+1<<endl;
ptr[i]->putdata();
}
getch();
}
ronaldo
male
brazil
25
enter
another(y/n)
y
enter
name,sex,designation,age
aishwarya
female
kottayam
22
enter
another(y/n)
n
person number:1
name:ronaldo
sex:male
designation:brazil
age:25
person number:2
name:aishwarya
sex:female
designation:kottayam
age:22
0 comments:
Post a Comment