Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 344383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:59:07+00:00 2026-05-12T10:59:07+00:00

Hehe I’m having hard time on choosing the question title. But let me explain

  • 0

Hehe I’m having hard time on choosing the question title. But let me explain about my problem to make it clearer.

I’m now writing my own GUI library for my game in C++ with a DirectX wrapper out there.
But I got no idea on how to render my in-game windows by just calling the “manager” class’s draw function.

For example, say I have a “manager” and “window” class already.

the manager:

class MyGUIManager
{
private:
  std::vector<MyGUIWindow> WindowCollector;
public:
  MyGUIManager()
  {
  }
  virtual MyGUIWindow *NewWindow(char *szWindowTitle)
  {
    MyGUIWindow *temp = new MyGUIWindow();
    temp->SetWindowTitle(szWindowTitle);
    return temp;
  }
  void RegisterWindow(MyGUIWindow targetWindow) // hopely this 
  {
    this->WindowCollector.push_back(targetWindow);
  }
  void Draw()
  {
    // I wanted this function to be able to call all MyGUIWindow instances' Draw() function
    // can it be helped like this?
    for(int i = 0; i < this->WindowCollector.size(); i++)
      this->WindowCollector.at(i)->Draw(); // but the vector members must be referenced to each window instance..
  }
};

the window:

class MyGUIWindow
{
public:
  MyGUIWindow()
  {
    this->SetWindowTitle("New Window");
  }
  void SetWindowTitle(char *szWindowTitle);
  void Draw();
};

and the main program:

//...
  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
    //...
  }

so the main question is, how to make all of MyGUIWindow variables can be controlled through WindowCollector vector?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T10:59:08+00:00Added an answer on May 12, 2026 at 10:59 am

    Yes basically that will work, why don’t you just try it out? But I would prefer using iterators instead of your loop, and also some kind of auto-pointer instead of just new (current example will probably cause a memory leak).

    Actually, begin by Googling std::vector… And passing arguments as references.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically I want to do the opposite of what this guy did... hehe. Python
I would like to give a class a unique ID every time a new
I'm experimenting with a personal finance application, and I'm thinking about what approach to
I'm not that good in OOP or even C# but I want to try
I found that PHP5 isn't calling a __destruct() function if I have the following
If I add an after_save callback to an ActiveRecord model, and on that callback
What term do I use to lookup documentation for old school .asmx web services
Consider: command1 | command2 Is the output of command1 used as standard input of
I am new in web services so apologize me if I am making some
I'd like to throw together a small game and put it online. It would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.