满意答案
asd0643
2014.09.11
采纳率:46% 等级:9
已帮助:313人
#include
#include
static char *strsave(char *s)
{ char *p;
p = new char[strlen(s)+1];
strcpy(p,s);
return p;
}
class student{
char *name;
char sex;
int age;
char *sbo;//班级
public:
student(char *name1,char sex1,int age1,char *sbo1)
{
name = strsave(name1);
sex = sex1;
age = age1;
sbo = strsave(sbo1);
}
~student()
{
4102delete[]name;
delete[]sbo;
}
int show()
{
cout<
cout<
cout<
cout<
return 0;
}
};
int main()
{
char *a,*b;
char c;
int d;
a = new char(9);
cout<
cin>>a;
cout<
cin>>c;
cout<
cin>>d;
b = new char(8);
cout<
cin>>b;
student A(a,c,d,b);
A.show();
return 0;
}
属性的设置是干1653嘛的
01分享举报