I am still new with c++ and I was told that #pragma once was supposed to take care of circular dependencies
My GameManager.h and GameSetting.h both need to know each other and each have a pointer of the other
for my GameSettings.h i have:
#pragma once
#include "PlayerManager.h"
#include <fstream>
#include "GameManager.h";
class GameSettings {
private:
PlayerManager* pM;
GameManager* gM;
vector<Player*> players;
bool inGame = false;
double betValue = 5;
bool allowSplit = true;
bool allowInsurance = true;
GameSettings(PlayerManager* pM, GameManager* gM) { this->pM = pM; this->gM = gM; }
struct GameSettingData {
vector<int> playersId;
double betValue;
bool allowSplit;
bool allowInsurance;
};
... function declarations...
for the GameSettings.cpp I only have the #include "GameSettings.h"
And for the GameManager I only have
#pragma once
#include "GameSettings.h"
class GameManager {
private:
bool isActive = false;
GameSettings *gS;
public:
bool getIsActive() { return isActive; }
bool startGame() { return true; }
};
When I remove any mention of GameSettings in GameManager everything work
I mostly know c# so this kind of circular dependencies is kind of new for me. I did try to look at other similar questions but it did not help