error C2146: syntax error : missing ';' before identifier

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#pragma once

#include <iostream>
#include <Windows.h>
#include "Lottery.h"

using namespace std;

class Quest
{
private:
	static HANDLE hConsole;
public:
	Quest();
	~Quest();

	int oneA();
	void answerBOne(bool);
	void clear();
};


Can't for the life of me why this isn't working... all the normal ways don't seem wrong
Which line has the problem?
Can you show Lottery.h?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#pragma once

#include "Quest.h"
#include "Ticket.h"
#include "Player.h"
#include "DisplayGames.h"
#include "Draw.h"
#include "Balance.h"
#include <list>
#include <windows.h>

class Lottery
{
private:
	int week;
	list<Ticket> ticket;
	list<Balance> balance;
	Player player;
	DisplayGames displayGames;
	Draw draw;
	Quest quest;
	static HANDLE hConsole;
public:
	Lottery();
	~Lottery();
	
	int running();
	void readFromFile();
	void weekControl();
	void pressEnterToContinue();
	void storage(list<Ticket>, list<Balance>);
	void clear();
};


didn't realize was the wrong one :') it's line 21 :)
the problem is that you include "Quest.h" in "Lottery.h" and vice versa which is not possible. Remove line 5 from "Quest.h". it is not even needed
@coder777
Is that causing this particular compiler error? Your solution seems to address circular dependencies includes, which should already be handled by #pragma once .

@bilbsyy
I don't see a missing semicolon in your code you've posted. Inside all the files you've included, double-check that your class declarations all end in a semicolon.
Last edited on
Is that causing this particular compiler error? Your solution seems to address circular dependencies, which should already be handled by #pragma once .


#pragma once stops header files from being included more than once in the same translation unit. They don't magically fix circular dependencies.


Last edited on
Feel really stupid thanks coder :')
Topic archived. No new replies allowed.