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

C++Class DesignCompilation

C++ Problem Overview


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.

C++ Solutions


Solution 1 - C++

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.

Solution 2 - C++

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

Solution 3 - C++

Class declaration ends with a semicolon.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionjDOGView Question on Stackoverflow
Solution 1 - C++Chris PitmanView Answer on Stackoverflow
Solution 2 - C++Kirill V. LyadvinskyView Answer on Stackoverflow
Solution 3 - C++tojasView Answer on Stackoverflow