new types may not be defined in a return type - C++

五迷三道 提交于 2019-12-03 08:04:08

问题


I am confused I think on C++ class structure.

I have a .h called FxMathFunctions.h and a .cpp called FxMathFunctions.cpp

the .h starts like:

class  FxMathFunctions
{
    public:
        FxMathFunctions();
        ~FxMathFunctions();

and in the .cpp

I have:

#include "FxBasicTypes.h"
#include "FxMathFunctions.h"

FxMathFunctions::FxMathFunctions() {}

FxMathFunctions::~FxMathFunctions() {}

I am getting errors like:

error: new types may not be defined in a return type
error: return type specification for constructor invalid

This must be something to do with definition someplace, but I just dont see where this might occur.


回答1:


What does your .h file end with? I'm guessing that the end of your class defnition does not have a ";". The class is being interpreted as the return type of the first function in your cpp file.




回答2:


Losing ; in the end of class declaration could lead to such error.




回答3:


Class declaration ends with a semicolon.



来源:https://stackoverflow.com/questions/3198750/new-types-may-not-be-defined-in-a-return-type-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!