Compiler says syntax error when I see nothing wrong

I don’t know how this broke. I was trying to give an unrelated method input parameters, that didn’t work, then when I removed them this starts breaking. The error literally says syntax error: identifier 'Puzzle'.

// Part of Instruments.h
#include "Puzzles.h"



	void SetWorld(Puzzle *A, Puzzle *B); // Compiler error
	void Print();

	void RefreshAll();
	void RefreshLights();
	void RefreshPortalColor();
	void RefreshMonitorNumber();
	void RefreshEnergyLevel();

	void CopyLights();

Which doesn’t make sense because I’m including Puzzles.h which as Puzzle defined.

// Puzzles.h
class Puzzle{
	int id;
	int GetID(){return id;}
	virtual bool IsSolutionCorrect(){return false;}
	//virtual bool IsSolutionCorrect(Instruments *inst, Input *input){return false;}

Am I missing something?

So it seems my header isn’t even being compiled. I do know what do.

What do you mean your header file isn’t being compiled? Are you getting a “fatal error C1083: Cannot open include file: ‘Puzzles.h’: No such file or directory”? Are your header files in your Source/.../Public folder?

No I’m not getting any errors like that. The only error I’m getting is syntax error: identifier 'Puzzle'. So it sounds like my Puzzle class isn’t being defined. I’m trying to use Puzzle as an interface and I have another class that uses variable of Puzzle as method parameters, so its being included in multiple headers for other classes.

This could happen if you have two headers that depend on each other. Instead of #include Puzzles.h class, you could use a forward declaration. Just put the line class Puzzle; in your Instruments.h file, above the Instruments class definition and add #include Puzzles.h to your Puzzles.cpp file.

I forgot about forward declaration before when I was using a single source. I tried including every header where methods were using class types as parameters which I now see is a bad idea. That solved my first problem that caused this one. Thanks.

Solved using forward declaration. See comments.

Converted the comment to an answer :-). Please mark it as correct so I get my karma!