obj\Debug\Media\Code\Game.o||In function `ZN4Game13processEventsEv':|
Game Engine\Media\Code\Game.cpp|22|undefined reference to `Game::screen'|
obj\Debug\Media\Code\Game.o||In function `ZN4Game6updateEN2sf4TimeE':|
Game Engine\Media\Code\Game.cpp|28|undefined reference to `Game::screen'|
obj\Debug\Media\Code\Game.o||In function `ZN4Game6renderEv':|
Game Engine\Media\Code\Game.cpp|34|undefined reference to `Game::screen'|
I don't know why this is happening. where i am learning from has got the same code and it apparently works.
Note that we are not defining the variable in line 3. We are just telling, there is a class attribute called value of type integer, but it was never created.
Note that you are not defining the variable in line 27. You are just telling, there is a class attribute called `screen' of type `std::shared_ptr<Screen>', but it was never created.
> int A::value = 42; //creating the class attribute
std::shared_ptr<Screen> Game::screen; //creating the class attribute (¿what value should it have?)
In order to improve that information, I would like you to tell me what parts make it confusing to relate the example with your code
I have another shared_ptr problem and i thought it was best to ask it here without starting a new thread.
i am wanting it to go to GameScreen when i click the play button. i have the play button working but when i try to compile the following code i get an error which will follow the code.
There is more to this code but to make this post smaller i removed the irrelevant parts
Menuscreen.cpp
mingw\bin\..\lib\gcc\mingw32\4.7.1\include\c++\bits\shared_ptr_base.h|908|error:
no matching function for call to 'std::__shared_ptr<Screen, (__gnu_cxx::_Lock_policy)1u>::__shared_ptr
(std::remove_reference<std::__shared_ptr<GameScreen, (__gnu_cxx::_Lock_policy)1u>&>::type)'|
note: candidates are: template<class _Alloc, class ... _Args> std::__shared_ptr::__shared_ptr
(std::_Sp_make_shared_tag, const _Alloc&, _Args&& ...)|