hi to al
i was doin some programming till i encountered this problem in the followin code...
i am nt able to find anythn wrong with the code bt it's nt showing the right result.
#include<iostream>
#include<conio.h>
using namespace std;
class person
{
char* name;
public:
void get()
{
cout<<"enter name=";
cin>>name;
}
void show()
{
cout<<name<<endl;
}
};
int main()
{
person* p[10];
int n=0;
char choice;
do
{
p[n]=new person;
p[n]->get();
n++;
cout<<"enter another(y/n):";
cin>>choice;
}while(choice=='y');
for(int i=0;i<n;i++)
{cout<<"person "<<(i+1)<<" is ";
p->show();
}
getch();
return 0;
}
it's actually showing the data entered fr the last object even at place of the other objects.....thanx in advance