python设计一个学生类、包括学号、姓名、性别_设计一个Student类。该类包含学生的姓名、性别、年龄和班级以及构造方法、这些属性的设置和显示。 要求:...

满意答案

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分享举报


版权声明:本文为weixin_36128337原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。