#include<iostream>using namespace std;class CStudent{ public: CStudent(char nam,int num,int gra1,int gra2,int gra3):name(nam),number(num),grade1(gra1),grade2(gra2),grade3(gra3){} void display() { cin>>name>>number>>grade1>>grade2>>grade3; int z=(grade1+grade2+grade3)%3; cout<<name<<number<<grade1<<grade2<<grade3<<z<<endl; } private: char name; int number; int grade1; int grade2; int grade3;};int main(){ CStudent stud1; stud1.display(); return 0;}
1 回答
已采纳
眼前的黑不是黑zz
TA贡献57条经验 获得超42个赞
你好。在main函数里面,
CStudent stud1; //你没有传入参数,当然编译不过了。 CStudent stud1('a', 123, 5, 6, 7); //你要像这样,传入对应的参数才可以
- 1 回答
- 0 关注
- 1084 浏览
添加回答
举报
0/150
提交
取消