C++ A class constructor (solved)

Trying something new, so naturally, I am confused.

I have a “screen” class:

class Screen
{
public:
	virtual void Switch() ;
	virtual  int Loop(unsigned long ms)=0;
};

The idea is to have a variable pointing to an object of this class so I can switch from one object to another by changing this variable.

So one of the “screens” is the “TemperatureScreen”

class TempScreen: public Screen
{
	int TempCol = 0 ;
	unsigned long nextMeatTime = 0 ;
	unsigned long nextChamberTime = 0 ;
	unsigned int BkColor ;
	void ShowTemp( int Pin, int y);

public:
	TempScreen() ;
	virtual void Switch() ;
	virtual  int Loop(unsigned long ms);
};

You see this is a screen with some members, including the required Switch and Loop.

So the constructor in .cpp file is simple:

TempScreen::TempScreen()
{
	BkColor = tftBLUEVIOLET ;
}

But the compiler always complains that TempScreen::TempScreen does not name a type. As far as I can tell, it isn’t supposed to, but you just can’t win an argument with a compiler.

Compiler doesn’t seem to understand that the cpp file contains the methods mentioned in the .h file. I got rid of the constructor, but the methods fail.

Maybe my .h files need to be .hpp files?

Forgot to include the .h file in the .cpp file

1 Like

Thank you for putting your solution!