#include <iostream.h>
class Phone
{
public:
Phone( )
{
name[0]='/0';
tel[0]='/0';
}
Phone(char * n,char *t)
{
strcpy(name,n);
strcpy(tel,t);
}
void setName(char * n)
{
strcpy(name,n);
}
void setTel(char * t)
{
strcpy(tel,t);
}
char * getName()
{
return name;
}
char * getTel()
{
return tel;
}
void display()
{
cout<<name<<" "<<tel<<endl;
}
private:
char name[10];
char tel[15];
};
int main()
{
Phone *p1=new Phone[3]; //鐢熸垚鍔ㄦ€佹暟缁?
p1->setName("zhang");
p1->setTel("13547858466");
p1->display();
(p1+1)->setName("wang");
(p1+1)->setTel("0731-888888");
(p1+1)->display();
(p1+2)->setName("li");
(p1+2)->setTel("0731-6666666");
(p1+2)->display();
p1[0].setName("cheng");
p1[0].setTel("13307336666");
p1[0].display();
p1[1].setName("hu");
p1[1].setTel("0731-9999999");
p1[1].display();
p1[2].setName("wu");
p1[2].setTel("0731-11111111");
p1[2].display();
delete [] p1;
return 0;
}