1.定义一个学生类(类名为:student)要求包含以下成员:

1.定义一个学生类(类名为:student)要求包含以下成员:
私有数据成员:学号,姓名,班级,所在系部,籍贯,邮政编码。
公有函数成员:构造函数(完成学生信息的初始化)析构函数,输出函数,Displayinfo(完成数据成员的输出),信息修改函数modifyinfo(完成修改学号功能)。

public class student
{
private String xuehao;
private String xingming;
private String banji;
private String xibu;
private String jiguan;
private String youbian;

public student(String xuehao,String xingming,String banji,String xibu,String jiguan,String youbian)//构造函数
{
this.xuehao=xuehao;
this.xingming=xingming;
this.banji=banji;
this.xibu=xibu;
this.jiguan=jiguan;
this.youbian=youbian;
}

~student( ) //析构函数
{ }

public Displayinfo(student a)
{
String s; s=a.xuehao+"\t"+a.xingming+"\t"+a.banji+"\t"+a.xibu+"\t"+a.jiguan+"\t"+a.youbian;
System.out.println(s);
}
public modifyinfo(student a,String xuehao)//修改具体学生a的学号
{
a.xuehao=xuehao;
}
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-10-17
#include<iostream>
using namespace std;
class student
{
public:
student(long number,string name,string system,stringjiguan,long postalcode);
~student();
void Displayinfo(number,name,system,jiguan,postalcode);
void modifyinfo(long a);
private:
long number;
string name;
string system;
stringjiguan;
long postalcode;
}
void class::Displayinfo(number,name,system,jiguan,postalcode)
{
cout<<"class: "<<number <<"name: "<<name <<"system: "<<system< <"jiguan: "<<jiguan <<"postalcode: "<<postalcode<<endl;
}
void class::modifyinfo(long a)
{
number=a;
}
int main()
{本回答被网友采纳
相似回答