In a project I am working on, I have to initialize a window and pass it as a parameter to another constructor, but before the window is initialized, it is passed as a parameter thus causing an error. Here is some code to give you a better idea of what I am talking about:
1 2 3 4 5 6
Game::Game()
: mWindow(sf::VideoMode(640, 480), "SFML Application", sf::Style::Close)
, mWorld(mWindow) //<---- right here is where the mWindow variable needs to be passed
{
//...
}
#include <iostream>
class A{
public:
A(){ std::cout <<"A\n"; }
};
class B{
public:
B(){ std::cout <<"B\n"; }
};
class C{
B b;
A a;
public:
C(): a(), b(){}
};
class D{
A a;
B b;
public:
D(): a(), b(){}
};
int main(){
C c;
D d;
}