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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:06:34+00:00 2026-05-26T22:06:34+00:00

I’m new to C++ and am porting over code from Java. I have a

  • 0

I’m new to C++ and am porting over code from Java. I have a renderer class which has a method that takes an interface as an argument. This way the caller can define how to render its buffers. Now I’m running into trouble when I try to ‘new’ the ported over class. I get the error ‘allocating an object of abstract class type’. This is the part of my code that I think I need to do something about:

// Interface to the OpenGL ES renderer; consumed by GLView
struct IRenderingEngine {
virtual void initialize(int width, int height) = 0;
virtual void render() const = 0;
virtual ~IRenderingEngine() {}
};

class Renderer : public IRenderingEngine
{
public:
    ...

class IDrawGLBuffer
{
public:
    virtual ~IDrawGLBuffer() {};
    virtual void function(VBODescription vboDescription,
                          ShaderDescription shaderDescription);
};

class ShaderDescription
{
public:
    ShaderDescription(){};
    ShaderDescription(string vertexShaderText,
                      string fragmentShaderText,
                      map<string,GLint>& variableMap,
                      IDrawGLBuffer& callback,
                      int vertexDimensions);
    GLuint getProgramID() const {return shaderProgramID;};
    int getVertexDimensions() const {return vertexDimensions;};
    friend class Renderer;
private:
    string vertexShaderText;
    string fragmentShaderText;
    GLuint shaderProgramID;
    IDrawGLBuffer callback;
    int vertexDimensions;
    map<string,GLint> variableMap;
};

class VBODescription
{
public:
    VBODescription(){};
    VBODescription(string shaderName,
                   map<string, Buffer>& variableMap,
                   GLenum usage,
                   int indexTotal,
                   GLuint textureID);
    int getIndexTotal() const {return indexTotal;};
    GLuint getTextureID() const {return textureID;};
    friend class Renderer;
private:
    GLenum usage;
    map<string, Buffer> variableMap;
    string shaderName;
    int indexTotal;
    GLuint textureID;

};

    ...

};
  • 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-26T22:06:35+00:00Added an answer on May 26, 2026 at 10:06 pm

    You shouldn’t, and can’t easily, include the interface directly in the class as you’ve done:

    IDrawGLBuffer callback;
    

    This allocates space for the interface only (which doesn’t take any room, being abstract), and you can’t know the size of any implementation (it could and probably does inherit the interface and add private members).

    What you should do is pass a pointer to the implementation of the interface, and then store that:

    Ctor(IDrawGLBuffer * pDrawImpl);
    std::shared_ptr<IDrawGLBuffer> m_DrawImpl;
    

    You then call methods from the interface using the pointer syntax (a->b(c)).

    Since it’s not possible for the compiler to know how big an implementation of an interface will be later, using pointers to reference the memory (which is somewhat known) becomes very important.

    I used a shared_ptr here to help automatically release the impl, although you may need a CComPtr or if your class is a bit odd, boost::intrusive_ptr. When working with interfaces, smart pointers are your friend (more than regularly).

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have thousands of HTML files to process using Groovy/Java and I need to
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a jquery bug and I've been looking for hours now, I can't

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.