c++ - Static class function in different class -
i trying call static function areamap::staticinitialize(model *) method in class view. compiles when define class areamap first error show below when try declaring view first though forward declared areamap. know way keep definition of view @ top?
#ifndef view_h #define view_h #include "model.h" class areamap; class view { public: void linkmvc(model * m) { model = m; areamap::staticinitialize(m); } model * model; }; class areamap { public: void static staticinitialize(model * m) { model = m; } model * model; }; #endif
error:
inc/view.hpp: in member function ‘void view::linkmvc(model*, controller*)’: inc/view.hpp:36:7: error: incomplete type ‘areamap’ used in nested name specifier areamap::staticinitialize(m);
#ifndef view_h #define view_h class areamap; class view { public: void linkmvc(model * m); model * model; }; class areamap { public: void static staticinitialize(model * m) { model = m; } model * model; }; void view::linkmvc(model * m) { model = m; areamap::staticinitialize(m); } #endif
however, still shouldn't compile. staticinitialize()
attempts modify non-static member variable.
Comments
Post a Comment