jDOG
jDOG

Reputation: 1201

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

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.

Upvotes: 57

Views: 58720

Answers (4)

Sam Ginrich
Sam Ginrich

Reputation: 841

... enum declaration ends with a semicolon.

Upvotes: 1

Chris Pitman
Chris Pitman

Reputation: 13104

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

Upvotes: 159

tojas
tojas

Reputation: 225

Class declaration ends with a semicolon.

Upvotes: 17

Kirill V. Lyadvinsky
Kirill V. Lyadvinsky

Reputation: 99575

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

Upvotes: 37

Related Questions