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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:41:01+00:00 2026-05-14T06:41:01+00:00

I have a question about a problem I’m struggling with. Hope you can bear

  • 0

I have a question about a problem I’m struggling with. Hope you can bear with me.

Imagine I have an Object class representing the base class of a hierarchy of physical objects. Later I inherit from it to create an Object1D, Object2D and Object3D classes. Each of these derived classes will have some specific methods and attributes. For example, the 3d object might have functionality to download a 3d model to be used by a renderer.

So I’d have something like this:

class Object {};
class Object1D : public Object { Point mPos; };
class Object2D : public Object { ... };
class Object3D : public Object { Model mModel; };

Now I’d have a separate class called Renderer, which simply takes an Object as argument and well, renders it 🙂
In a similar way, I’d like to support different kinds of renderers. For instance, I could have a default one that every object could rely on, and then provide other specific renderers for some kind of objects:

class Renderer {};  // Default one
class Renderer3D : public Renderer {};

And here comes my problem. A renderer class needs to get an Object as an argument, for example in the constructor in order to retrieve whatever data it needs to render the object.

So far so good. But a Renderer3D would need to get an Object3D argument, in order to get not only the basic attributes but also the specific attributes of a 3d object.

Constructors would look like this:

CRenderer(Object& object);
CRenderer3D(Object3D& object);

Now how do I specify this in a generic way? Or better yet, is there a better way to design this?

I know I could rely on RTTI or similar but I’d like to avoid this if possible as I feel there is probably a better way to deal with this.

Thanks in advance!

  • 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-14T06:41:02+00:00Added an answer on May 14, 2026 at 6:41 am

    One approach would be to allow the Objects to create their own Renderer’s though a getRenderer() method which returns a Renderer of the appropriate type. This is an example of the Factory Method pattern. Depending on the features of your implementation language, the getRenderer method could be an abstract method in your parent Object class with return an instance of a parent Renderer class/interface, which the specific Renderers extend/implement.

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

Sidebar

Related Questions

No related questions found

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.