c++编程的问题
源代码#include<iostream.h>classCStuScore{public://共有类型声明charstrName[12];//姓名charstrStuNO...
源代码
#include<iostream.h>
class CStuScore
{
public: //共有类型声明
char strName[12]; //姓名
char strStuNO[9]; //学号
void SetScore(float s0,float s1,float s2) //成员函数:设置3门课程成绩
{
fScore[0]=s0; fScore[1]=s1; fScore[2]=s2;
}
float GetAverage();
private: //私有类型声明
float fScore[3]; //三门课程成绩
}; //注意分号不能省略
float CStuScore::GetAverage()
{
return(float)((fScore[0]+fScore[1]+fScore[2])/3.0);
}
void main()
{
CStuScore={"strName","strStuNO",{s0,s1,s2}};
cout<<()StrName<<"strName的平均成绩为: "<<GetAverage()<<"\n";
}
--------------------Configuration: asdvvv - Win32 Debug--------------------
Compiling...
asdvvv.cpp
F:\Program Files\Microsoft Visual Studio\MyProjects\asdvvv\asdvvv.cpp(21) : error C2513: 'class CStuScore' : no variable declared before '='
F:\Program Files\Microsoft Visual Studio\MyProjects\asdvvv\asdvvv.cpp(21) : fatal error C1903: unable to recover from previous error(s); stopping compilation
Error executing cl.exe.
asdvvv.exe - 2 error(s), 0 warning(s)
总提示这些错误,怎么改啊?改对的有追加
怎么改是主要!!!!!! 展开
#include<iostream.h>
class CStuScore
{
public: //共有类型声明
char strName[12]; //姓名
char strStuNO[9]; //学号
void SetScore(float s0,float s1,float s2) //成员函数:设置3门课程成绩
{
fScore[0]=s0; fScore[1]=s1; fScore[2]=s2;
}
float GetAverage();
private: //私有类型声明
float fScore[3]; //三门课程成绩
}; //注意分号不能省略
float CStuScore::GetAverage()
{
return(float)((fScore[0]+fScore[1]+fScore[2])/3.0);
}
void main()
{
CStuScore={"strName","strStuNO",{s0,s1,s2}};
cout<<()StrName<<"strName的平均成绩为: "<<GetAverage()<<"\n";
}
--------------------Configuration: asdvvv - Win32 Debug--------------------
Compiling...
asdvvv.cpp
F:\Program Files\Microsoft Visual Studio\MyProjects\asdvvv\asdvvv.cpp(21) : error C2513: 'class CStuScore' : no variable declared before '='
F:\Program Files\Microsoft Visual Studio\MyProjects\asdvvv\asdvvv.cpp(21) : fatal error C1903: unable to recover from previous error(s); stopping compilation
Error executing cl.exe.
asdvvv.exe - 2 error(s), 0 warning(s)
总提示这些错误,怎么改啊?改对的有追加
怎么改是主要!!!!!! 展开
6个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询