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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:27:51+00:00 2026-05-22T03:27:51+00:00

I am doing some game design, and decided that I want a data centric

  • 0

I am doing some game design, and decided that I want a data centric model… one “game data” object which gets passed from subsystem to subsystem, and knows itself how it should be drawn, how physics should operate on itself, how inputs from the user will affect it etc.

So I started out with “Listener”ish objects like “BaseRenderer” “BaseInputHandler” etc:

class BaseRenderer
{
public:
    virtual void Render(BITMAP *b) = 0;
};

class BaseInputHandler
{
public:
    virtual int TakeInputs() = 0;
};

And created a “GameData” object which inherits from these…

class GameData : public BaseRenderer, public BaseInputHandler, public BaseCalculator
{
public:
    /* Virtual Overwrites: (each child of GameData will need to overwrite these!) 
    void Render(BITMAP *b);
    int TakeInputs();
    void Calculate();*/
};

And then each subsystem has a singleton which will execute the various operations (render, take inputs, etc) on the game data…

GameData gd; // Or inherited from GameData...
Input::System().Init();
...
while(loop) {
    loop &= !(Input::System().GetInputs(&gd));
    ...
}

Is this a valid and sensible way to do inheritance? The reason I ask is because I am getting obscure runtime crashes… Not allocating any dynamic memory. Last night I got a crash from adding 2 member functions to GameData (virtual or not virtual) and then it went away when I added them slowly (first 1 non-virtual, then 1 virtual, then 2 non-virtual etc).

I read something on SO (can’t remember where it was now) about inheritance and slicing. I didn’t really get it, but am I doing something dangerous with my inheritance which is causing intermittent runtime bugs?

Or should I look at my timing code which is using QueryPerformanceCounter?

MinGW + allegro

  • 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-22T03:27:51+00:00Added an answer on May 22, 2026 at 3:27 am

    Slicing occurs when you pass by value. If your base types are abstract (have pure virtual functions), slicing cannot occur; the compiler will complain instead. (Slicing occurs when an object is copied, but only the base class is copied.)

    As long as you’re not trying to use value semantics (pass by value, etc.), your hierarchy should be fine; most of the time, in such cases, I’ll forbid copy systematically, by having everything derive from boost::noncopyable, but this isn’t really necessary, as long as all of the bases are abstract.

    One other special issue to pay attention to is that all explicit conversions are on pointers or references (not values), and that they use the new style casts (dynamic_cast, in general). When multiple inheritance is involved, an C-style cast can accidentally end up being a reinterpret_cast, and the code will do strange things after that.

    In addition, of course, the usual issues apply: no dangling pointers, etc. (You say you have no dynamic allocation. I find this surprising if you have polymorphic types, which generally shouldn’t support copy.)

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

Sidebar

Related Questions

I want to get started doing some game development using Microsoft's XNA. Part of
Currently I'm doing some unit tests which are executed from bash. Unit tests are
I've been doing some mocking with RhinoMocks and it requires that mocked methods be
I'm doing some Objective-C programming that involves parsing an NSXmlDocument and populating an objects
I'm doing some work using the JavaMail API, and I've run across encodings which
After doing some work with Ruby, Rails, and RSpec last summer and I learned
I'm doing some PHP stuff on an Ubuntu server. The path I'm working in
I'm doing some funky authentication work (and yes, I know, open-id is awesome, but
I've been doing some HTML scraping in PHP using regular expressions. This works, but
I am doing some research on Unicode for a white-paper I am writing. Does

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.