m0_64509442 2022-04-14 09: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 09:23
    关注

    img


    多了一个分号

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

报告相同问题?

问题事件

  • 系统已结题 4月22日
  • 已采纳回答 4月14日
  • 创建了问题 4月14日

悬赏问题

  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入
  • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。
  • ¥15 opencv图像处理,需要四个处理结果图
  • ¥15 无线移动边缘计算系统中的系统模型
  • ¥15 深度学习中的画图问题
  • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条
  • ¥15 Python报错怎么解决
  • ¥15 simulink如何调用DLL文件
  • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离