using System;
public class person
{
public string name,sex;
public int age;
}
public class student:person
{
int chinese, meths, english;
double evg;
public student(int i,int j,int k)
{
chinese = i;
meths = j;
english=k;
}
public student(string a,string b,int m)
{
name = a;
sex = b;
age=m;
}
public void com()
{
evg = (double)((chinese + meths + english) / 3);
}
public void write()
{
Console.WriteLine("名字:{0} 性别:{1} 年龄:{2}\n", name, sex, age);
Console.WriteLine("成绩\nchinese:{0} methd:{1} english:{2}\n", chinese, meths, english);
Console.WriteLine("平均成绩:" + evg);
}
}
class text
{
static public void Main()
{
........
}
}
偶做到这就不懂做了
如何给构造函数:
public student(int i,int j,int k)
public student(string a,string b,int m)
传递参数呢?
这个程序的要求是: 由类person派生出student,并且要对构造函数最少要二次重载
基类有name,sex,age域。
在新人交流区 没人理 只好才发多一次了