Hello.
I have simple class called Board.hpp and Board.cpp.
I have also a DNBoard.hpp and DNBoard.cpp. I have a static variable in Board.hpp and I set that variable in Board.cpp. I need a static as the variable should have class scope.
However, when I try and access that variable from DNBoard.cpp I get a negative value and not the value that I set in the Board.cpp.
Board.hpp
Board.cppCode:class Board { public: static int bHandle(){return _bHandle;} private: static int _bHandle; };
DNBoard.hppCode:int Board::_bHandle = 0; //initialize void OpenLibrary() { Board::_bHandle = 101023; //Value I want to set and access in DNBoard.cpp
DNBoard.cppCode:#include "Board.hpp" class DNBoard : public Board { // some stuff here };
Code:void Service() { int handle = Board::bHandle(); //Give an incorrect value here }



LinkBack URL
About LinkBacks


