网页
资讯
视频
图片
知道
文库
贴吧
地图
采购
进入贴吧
全吧搜索
吧内搜索
搜贴
搜人
进吧
搜标签
日
一
二
三
四
五
六
签到排名:今日本吧第
个签到,
本吧因你更精彩,明天继续来努力!
本吧签到人数:0
一键签到
成为超级会员,使用一键签到
一键签到
本月漏签
0
次!
0
成为超级会员,赠送8张补签卡
如何使用?
点击日历上漏签日期,即可进行
补签
。
连续签到:
天 累计签到:
天
0
超级会员单次开通12个月以上,赠送连续签到卡3张
使用连续签到卡
03月22日
漏签
0
天
c++吧
关注:
606,092
贴子:
2,108,835
看贴
图片
吧主推荐
游戏
4
回复贴,共
1
页
<<返回c++吧
>0< 加载中...
求助
取消只看楼主
收藏
回复
贴吧用户_QUUNyS8
,
1
该楼层疑似违规已被系统折叠
隐藏此楼
查看此楼
贴吧用户_QUUNyS8
,
1
该楼层疑似违规已被系统折叠
隐藏此楼
查看此楼
希望得到的结果:
无锡锐赫新科技有限公司
运行库全能修复管家一键修复电脑软件和游戏缺失DLL、DirectX导致的崩溃、卡顿、故障等问题。百万用户已下载使用并推荐,一款值得信赖的
c++
神器。
2025-03-22 06:23
广告
立即查看
贴吧用户_QUUNyS8
,
1
该楼层疑似违规已被系统折叠
隐藏此楼
查看此楼
错误原因似乎是定义数组是只调用了无参构造函数,totalscore只在那时候加了:
贴吧用户_QUUNyS8
,
1
该楼层疑似违规已被系统折叠
隐藏此楼
查看此楼
不知道怎么解决,求大佬帮助一下
贴吧用户_QUUNyS8
,
1
该楼层疑似违规已被系统折叠
隐藏此楼
查看此楼
#include<iostream>
using namespace std;
class student{
private:
int id;
string name;
int score;
static int cnt;
static int totalscore;
public:
student(){
cnt++;
totalscore += score;
}
student(int a, string b, int c){
cnt++; this->id = a; this->name = b; this->score = c; totalscore += this->score; }
~student(){
totalscore -= this->score;
cnt--;
}
friend std::istream& operator>>(std::istream &in, student& m){
in >> m.id >> m.name >> m.score;
return in;
}
void show(){
cout << "学生总人数:" << cnt << endl << "平均分:" << totalscore / cnt << endl;
}
};
int student::cnt = 0;
int student::totalscore = 0;
int main(void){
int cnt ;
scanf("%d",&cnt);
student s[cnt];
for(int i=0;i<cnt;i++) { cin>>s[i]; }
student *t = new student(23,"hely",89);
s[0].show();
delete t; s[0].show();
}
登录百度账号
扫二维码下载贴吧客户端
下载贴吧APP
看高清直播、视频!
贴吧页面意见反馈
违规贴吧举报反馈通道
贴吧违规信息处理公示