new types may not define a return type - C++

来源:互联网 发布:java程序设计 编辑:程序博客网 时间:2024/05/19 23:01

Question:

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 typeerror: return type specification for constructor invalid
This must be something to do with definition someplace, but I just dont see where this might occur

Answer:

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.

0 0
原创粉丝点击