hello.
I'm trying to make a CWorld class that can only be constructed once, now Elysia told me the approach yesterday, still I forgot all the details so I've been mindless hacking for sometime, with only help from intellisense and some from cprogramming.com, still I ain't getting it right...
Those are the classes I have, now I'm supposed to be able to create many CWorld_Fac classes, still it will always lead to the same CWorld class, since it's static, also I have this code in main()Code:class CWorld { private: hgeVector m_hVec_ScreenSize; float m_Gravity; boost::array<std::string, 1> m_str_mapNames; void SetMapNames(); CWorld(const float gravity_); public: hgePolygonMap* m_map; friend class CWorld_Fac; // HGE needed functions e.g. the creation of the world... inline void SetStates(); static bool FrameFunc(); static bool RenderFunc(); }; class CWorld_Fac { public: CWorld_Fac::CWorld_Fac(const float gravity_) { static CWorld world_(gravity_); } };
now this should be having the right info, and thus making CWorld get the right info first time...Code:world = new CWorld_Fac(0.5f);
here is the call that fails
now here I set m_world argument to 0, this shouldn't change anything since the CWorld constructor was static in CWorld_fac, right?Code:CWorld_Fac m_world; // this fails CCharacter(std::string entClass_) : CEntity(HEL_MIDDLE2, false), m_world(0) { m_world.m_map->RegisterEntityClass(entClass_, this); }
Hope I was able to explain correctly, and thanks in advance!



LinkBack URL
About LinkBacks




