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 8953099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:01:27+00:00 2026-06-15T14:01:27+00:00

Curious if anyone has any ideas on this one; working on a game engine

  • 0

Curious if anyone has any ideas on this one; working on a game engine that implements a tree of GameObject’s. Various specific game objects inherit from that type ( BouncingBall, StatScreen, or whatever).

class GameObject {
    public:
    vector<Component *> Components;
    vector<GameObject *> Children;
    GameObject *Parent;
};

So at runtime, the game will have a huge tree of these, all of different types. Unfortunately the objects in the Children vectors are all reported as “GameObject *” in the debugger making it really hard to tell what’s what.

Best solution I’ve come up with is to store the type as a member variable on construction:

class GameObject {
    public:
    // ...
    const char *Type;

    // Saves current class name as Type.
    template<class T>
    void StoreTypeName( T *thisPointer ) {
        this->Type = typeid( *thisPointer ).name();
    }
};

But then in every object constructor I have to remember to call StoreTypeName:

class FancyBlinkingObject : public GameObject {
    public:
    FancyBlinkingObject() {
        StoreTypeName( this );
    }
};

Any other possible tricks to just do this automatically? Either on the debugger end (Visual Studio 2012) or in the code?

I thought of maybe some kind of central dynamic cast testing function:

if ( dynamic_cast<FancyBlinkingObject *>( basePointer ) ) {
    return "FancyBlinkingObject";
}
if ( dynamic_cast<UglyBlueObject *>( basePointer ) ) {
    return "UglyBlueObject";
}

But I can’t think of a way to do it without me having to manually maintain the list of if’s. Want something totally automatic if possible. 🙂

  • 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-06-15T14:01:29+00:00Added an answer on June 15, 2026 at 2:01 pm

    Per David Rodriguez’s comment – making GameObject polymorphic (in my case by making the destructor virtual) changed its classification in the debugger and showed a vptr to the runtime type info, which did the trick.

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

Sidebar

Related Questions

I'm just curious if anyone has any great ideas on this. We have a
I am using acts_as_commentable and am curious if anyone has any good ideas on
I am curious to see if anyone else has run into this same issue...
I was curious if anyone knows of any good examples of plugins that I
I'm curious if anyone has any good solutions for accurately building dates prior to
I'm just curious if anyone has done this before. I'd like to use the
I'm just curious if anyone has any tricks on how to keep source code
I was curious if anyone had any suggestions on a Java library that provides
I am curious if anyone has done a comparison between the different options out
I'm just curious to know if anyone has used (successfully) Fusion Charts with Open

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.