这是一个创建于 3605 天前的主题,其中的信息可能已经有所发展或是发生改变。
#include <iostream>
using namespace std;
class Student
{
private:
char *name;
float english, math, chinese;
public:
Student(char *n, float e, float m, float c)
{
name = n; english = e; math = m; chinese = c;
}
void showname()
{
cout << name << " ";
}
float avg()
{
cout << (english + math + chinese) / 3;
}
};
void main()
{
Student std[3] = {
Student("li", 77, 88, 99),
Student("chen", 78, 89, 90),
Student("wu", 87, 97, 67)
};
for (int i = 0; i < 3; i++)
{
std[i].showname;
std[i].avg;
}
}