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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:39:57+00:00 2026-05-25T13:39:57+00:00

I have the following class, class Simulation { public: btDefaultCollisionConfiguration collisionConfiguration; btBroadphaseInterface broadphase; btSequentialImpulseConstraintSolver

  • 0

I have the following class,

class Simulation {
public:
  btDefaultCollisionConfiguration collisionConfiguration;
  btBroadphaseInterface broadphase;
  btSequentialImpulseConstraintSolver solver;
  btDynamicsWorld dynamicsWorld;

  Simulation() {
    broadphase = btCollisionDispatcher(&collisionConfiguration);
  }
}

and when I compile I get this error

cannot declare field ‘Simulation::broadphase’ to be of abstract type ‘btBroadphaseInterface’

Now I think I know what I did wrong. If this compiled then the moment I called the constructor the memory allocated would be for a virtual class and wouldn’t contain the subclass(btCollisionDispatcher). I know how to solve this with pointers, but I’ve been hearing from people that you should advoid pointers in C++ and I thought I would give it a try. I’ve been successful so far but I don’t know what to do here.

  • 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-25T13:39:58+00:00Added an answer on May 25, 2026 at 1:39 pm

    Yeah, you can only have pointers or references to abstract classes because you can’t instantiate an abstract class because, by definition, it has an “incomplete” definition (not to be taken literally). It’s just an interface.

    If you want to avoid pointers, you can use references, like this:

    class Simulation {
    public:
      btDefaultCollisionConfiguration collisionConfiguration;
      btBroadphaseInterface& broadphase;
      btSequentialImpulseConstraintSolver solver;
      btDynamicsWorld dynamicsWorld;
    
      Simulation() : broadphase(someFunctionThatReturnsAbtBroadphaseInterfaceReference()) {
    
      }
    }
    

    Or smart pointers, like this:

    // header for shared_ptr
    #include <memory>
    
    class Simulation {
    public:
      btDefaultCollisionConfiguration collisionConfiguration;
      shared_ptr<btBroadphaseInterface> broadphase;
      btSequentialImpulseConstraintSolver solver;
      btDynamicsWorld dynamicsWorld;
    
      Simulation() : broadphase(someFunctionThatReturnsAbtBroadphaseInterfacePointerOrSmartPointer()) {
    
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following situation: class A { public: A(int whichFoo); int foo1(); int
Suppose you have the following situation #include <iostream> class Animal { public: virtual void
I have following class public class ButtonChange { private int _buttonState; public void SetButtonState(int
I have following class (as seen through reflector) public class W : IDisposable {
I have the following situation: typedef void (*F_POINTER)(ClassName*); class ClassName { public: F_POINTER f;
I have a problem with JPA 1.0 (OpenJPA) Following situation @Entity public class A{
I have following class: public class PairOfDice { private Dice d1,d2; public int Value
Assume I have the following class-hierarchy in C++: class AbstractBaseClass { public: // Note:
I have the following helper class (simplified): public static class Cache { private static
I have following situation class base { public: virtual void Accepted(SOCKET s) //// Event

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.