
VC2010 C++问题?
CRation::CRation(longn,longd){//对象创建时被调用this->n=n;//this是指向当前对象的指针this->d=d;}错误:error...
CRation::CRation( long n, long d )
{ // 对象创建时被调用
this->n = n; // this是指向当前对象的指针
this->d = d;
}
错误:
error C2533: “CRation::{ctor}”: 构造函数不能有返回类型
这个构造看起来没有返回类型啊,为什么他说有呢?
main( )
{
CRation r( 18,27 );// 分配空间,调构造函数
r.Print( ); // 输出
r.Gcd( ); // 约分
r.Print( );
}
: error C3874: “main”的返回类型应为“int”而非“CRation”
这个错误又要什么该呢? 展开
{ // 对象创建时被调用
this->n = n; // this是指向当前对象的指针
this->d = d;
}
错误:
error C2533: “CRation::{ctor}”: 构造函数不能有返回类型
这个构造看起来没有返回类型啊,为什么他说有呢?
main( )
{
CRation r( 18,27 );// 分配空间,调构造函数
r.Print( ); // 输出
r.Gcd( ); // 约分
r.Print( );
}
: error C3874: “main”的返回类型应为“int”而非“CRation”
这个错误又要什么该呢? 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询