首页 > 解决方案 > 构造函数的外联定义的返回类型与声明中的不同

问题描述

我有一个关于派生类构造函数的问题。

这是我的课 LeftV

class LeftV : public Body{
public:
    LeftV(string o, string name, int mag, string dir, char type);
    
};

和实施,

LeftV::LeftV(string o, string name, int mag, string dir, char type) : Body(o, name, mag, dir){
    this->type = type;
    
};

我收到以下错误,

“'LeftV::LeftV' 的外联定义的返回类型与声明中的不同。”

如果我声明的是构造函数,为什么它告诉我返回类型不同?

谢谢!

标签: c++constructorreturn-type

解决方案


推荐阅读