c++ - Defning a namespace class in a header file -
i have similar problem this not exact.
assuming have 2 header files , main.cpp. in first header file have :
namespace logic { class gamemanager; } in second header:
#include "first_header.h" class logic::gamemanager { public : void init(); void run(): }; and in main.cpp have :
#include "first_header.h" int main() { logic::gamemanager gm; gm.init(); gm.run(); } i error until include second header in main.cpp :
'gm' uses undefined class 'logic::gamemanager' -is way of using namespaces , classes correct ?
-is there better way this?
thanks.
re-open namespace define class.
namespace logic { class gamemanager { public : void init(); void run(): }; } and include second header, not first, main.cpp. compiler cannot find class definition unless directly #include'd.
Comments
Post a Comment