编写一个学生类students.

来源:百度知道 编辑:UC知道 时间:2024/06/03 15:33:26
该类包括学号no姓名name性别sex和年龄age成员变量;该类的成员方法有getNo.getName,getSex,getAge,setAge.

JAVA语言

public class students
{
private string no;
private string name;
private string sex;
private int age;

public string getNo()
{
return this.getNo;
}
public string getName()
{
return this.name;
}
public string getSex()
{
return this.sex;
}
public int getAge()
{
return this.age;
}
public void setAge(int iAge)
{
this.age = iAge;
}
}
数据类型的大小写可能需要调整一下

struct student{
int No.;
char name;
char sex;
int age;
}student;