m0_64509442 2022-04-14 01:06 采纳率: 83.3%
浏览 35
已结题

c加加 小问题 哪里出错

#include
using namespace std;
class Student
{public:
Student(int n , float s)
{num=n;
score=s;}
~Student()
{cout<<"a dui "<<endl;}
void display();
{cout<<"num:"<<num<<endl;
cout<<"score:"<<score<<endl;}
private:
int num;
float score;
};
int main()
{
Student stud1(1001,66.6);
stud1.display();
Student stud2(1002,99.9);
stud2.display();
return 0;
}

#include
using namespace std;
class Student
{public:
Student(int =1001 , float =66.6);

  void display();

private:
int num;
float score;
};
Student::Student(int n , float s):num(n),score(s)
{}
void Student::display()
{cout<<"num:"<<num<<endl;
cout<<"score:"<<score<<endl;}
int main()
{
Student stud1();
Student stud2(1002,99.9);
stud1.display();
stud2.display();
return 0;
}

img

img

展开全部

  • 写回答

1条回答 默认 最新

  • kinghero123456 2022-04-14 01:23
    关注

    img


    多了一个分号

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

问题事件

  • 系统已结题 4月21日
  • 已采纳回答 4月14日
  • 创建了问题 4月14日
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部