呵呵我很难选择问题标题。但让我解释一下我的问题,使其更清晰。注册类实例以受类的功能控制
我现在用C++编写我自己的GUI库,并带有DirectX包装器。 但是我不知道如何通过调用“manager”类的绘图函数渲染我的游戏窗口。
例如,假设我已经有一个“经理”和“窗口”类。
经理:
窗口:
class MyGUIWindow { public: MyGUIWindow() { this->SetWindowTitle("New Window"); } void SetWindowTitle(char *szWindowTitle); void Draw(); };
和主要程序:
//... MyGUIManager *GUIMAN = new MyGUIManager(); MyGUIWindow *FirstWindow = GUIMAN->NewWindow("Hello World"); MyGUIWindow *SecondWindow = GUIMAN->NewWindow("Hello World!!!"); GUIMAN->RegisterWindow(FirstWindow); // ?? GUIMAN->RegisterWindow(SecondWindow); while(Drawing()) { GUIMAN->Draw(); // I wanted this function to be able to call ALL MyGUIWindow instances' Draw() function //... }
所以主要的问题是,如何让所有MyGUIWindow变量都可以通过WindowCollector向量来控制?
GUIMAN-> RegisterWindow(FirstWindow); // ?? GUIMAN-> RegisterWindow(SecondWindow); 看起来像是在期待引用时传递指针,这是您遇到的问题吗? – 2009-09-01 12:21:43
是的!实际上我希望WindowCollector的每个成员在将它推回到RegisterWindow函数时引用targetWindow。 – 2009-09-01 12:25:59