【求助】头晕啊!指针
用指针数组表示姓名,地址,邮政编码。有很多问题,帮我改改,大虾!#include<iostream>
#include<string>
using namespace std;
class person
{
private:
string *p[3];
static int m;
public:
person(string *a);
~person();
void setname(string *name);
void show();
};
int person::m=1;
person::person(string *a)
{
cout<<"creat ""<<m<<"" person!"<<endl;
for(int i=0;i<3;i++)
{
p[i]=new string[strlen(a[i])+1];
strcpy(p[i],a[i]);
m++;
}
person::~person()
{
cout<<"delete"<<m-1<<"person!"<<endl;
}
void person::setname(string name)
{
p[0]=name;
}
void person::show()
{
cout<<"姓名:"<<person.p[0]<<endl;
cout<<"地址:"<<person.p[1]<<endl;
cout<<"邮政编码:"<<person.p[2]<<endl;
}
void main()
{
string *s[3]={"我我我","江西于都","10002'};
person p1(s);
p1.show();
char name;
cin>>name;
setname(name);
p1.show();
}