| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2178 人关注过本帖
标题:为什么too many initializers
只看楼主 加入收藏
登等等
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2017-9-1
收藏
 问题点数:0 回复次数:0 
为什么too many initializers
#include "iostream"
#include "cstring"
using namespace std;
class student{
private:
char stunum[15];
char Name[20];
int math;
int Chinese;
int Total;
double Ave;
public:
student(char s[]="0",char N[]="0",int m=0,int C=0);
void input();
void print();
};

student::student(char s[],char N[],int m,int C){
strcpy(stunum,s);
strcpy(Name,N);
math=m;
Chinese=C;
Total=math+Chinese;
Ave=Total/2;
}

void student::input(){
cout<<"please input student number"<<endl;
cin.getline(stunum,15);
cout<<"please input name"<<endl;
cin.getline(Name,20);
cout<<"please input math"<<endl;
cin>>math;
cin.get();
cout<<"please input Chinese"<<endl;
cin>>Chinese;
cin.get();
Total=math+Chinese;
Ave=Total/2;
}

void student::print(){
cout<<"学号"<<stunum<<endl;
cout<<"姓名"<<Name<<endl;
cout<<"数学"<<math<<endl;
cout<<"语文"<<Chinese<<endl;
cout<<"总分"<<Total<<endl;
cout<<"平均分"<<Ave<<endl;
}

void main(){
int i,n;
student a[10]={{"1651030101","zhang",92,93},{"1651030102","wang",94,92},{"1651030103","li",95,92},{"1651030104","zhao",97,98},{"1651030105","qian",25,65},{"1651030106","sun",75,45},{"1651030107","hao",67,94}};
for(i=6;i<n;i++)
a[i].input();
for(i=0;i<n;i++)
a[i].print();
}
Desktop\2.cpp(53) : error C2078: too many initializers

[此贴子已经被作者于2017-9-1 17:39编辑过]

搜索更多相关主题的帖子: student int math Chinese cout 
2017-09-01 17:35
快速回复:为什么too many initializers
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014252 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved