请帮忙看下什么原因?
#include <iostream.h>
#include <string.h>
class account
{
private:
char* name;
char* ID;
char* address;
char zhanghao[20];
public:
account* next;
account* creat();
account* serach(char* e);
};
account a;
account* head;
account* account::creat()
{
int s=1;
account *p,*p1;
p=new account;
cout<<"输入你的帐号:"<<endl;
cin>>p->zhanghao;
cout<<"输入你的姓名:"<<endl;
cin>>p->name;
cout<<"输入你的身份证:"<<endl;
cin>>p->ID;
cout<<"输入你的地址:"<<endl;
cin>>p->address;
head=NULL;
p1=p;
while(s)
{
if(head==NULL)
{
head=p;
}
else
{
p1->next=p;
}
p=new account;
cout<<"1.继续输入"<<endl;
cout<<"2.返回"<<endl;
cout<<"请选择:"<<endl;
cin>>s;
if(s==1)
{
cout<<"输入你的帐号:"<<endl;
cin>>p->zhanghao;
cout<<"输入你的姓名:"<<endl;
cin>>p->name;
cout<<"输入你的身份证:"<<endl;
cin>>p->ID;
cout<<"输入你的地址:"<<endl;
cin>>p->address;
}
else
{
s=0;
}
}
delete p;
return head;
}
main()
{
int s=1,sec;
while(s)
{
cout<<"1.新建帐户."<<endl;
cout<<"2.查询帐户."<<endl;
cout<<"3.返回上级菜单."<<endl;
cout<<"请输入你的选择:"<<endl;
cin>>sec;
if(sec==1)
{
head=a.creat();
}
}
}
程序运行到cout<<"输入你的帐号:"<<endl;
cin>>p->zhanghao;
处就出错,我把account类中的char* zhanghao改成char zhanghao[20]运行就可以,请问这个是为什么?还有->和.2个符号有什么不同?各在什么情况下用?