构造函数不能有返回类型
#include "StdAfx.h"
#include "Score.h"
CScore::CScore(void)
{
}
CScore::~CScore(void)
{
}
CScore::CScore(int n,CString na,CString cl,int ma,int eng, int comp)
{
m_Number=n; m_Name=na;
m_Class=cl; m_Math=ma;
m_English=eng; m_Computer=comp;
}
CScore::CScore(const CScore& s1)
{
m_Number=s1.m_Number;m_Name=s1.m_Name;
m_Class=s1.m_Class;m_Math=s1.m_Math;
m_English=s1.m_English;m_Computer=s1.m_Computer;
}
double CScore::aver(void)
{
return (m_Math+m_English+m_Computer)/3.0;
}
错误error C2533: “CScore::{ctor}”: 构造函数不能有返回类型
可是CScore()构造函数本来就没写返回类型啊。
[解决办法]
类声明末尾没加分号,相当常见的错误
多注意一下