C++: Error: Indirect nonvirtual base class is not allowed

Brandon White

I'm trying to create some sort of basic UI in c++ and OpenGL. With this I am using a class called OGLRectangle:

class OGLRectangle : public Renderable, public Listener
{
public:
                    OGLRectangle();
                    OGLRectangle(float cX, float cY);
                    ~OGLRectangle();
...
}

this is inherited by a Button class that contains shared methods between all button types:

 class Button : public OGLRectangle

finally the class of ButtonBrowse inherits from this and contains methods for file opening:

class ButtonBrowse : public Button
{
    public:
        ButtonBrowse(float cX, float cY);
...
}

Now would I be right in saying that to pass the parameters of the constructor in ButtonBrowse I need to do something like this in the constructor:

ButtonBrowse::ButtonBrowse(float cX, float cY) : OGLRectangle(cX, cY)
{
...
}

and if so why am I getting the indirect nonvirtual error that's in the title?

Lawrence Aiello

You need to call the constructor of Button, which will then call the OGLRectangle constructor.

ButtonBrowse::ButtonBrowse(float cX, float cY) : Button(cX, cY)
{
...
}

As long as Button has its constructor set up to pass parameters up to its direct base class OGLRectangle, you should be fine.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

C++ error: object of abstract class type is not allowed

From Dev

error C2504: base class undefined

From Dev

Error C2504 - Base class undefined

From Dev

Error C2504 - Base class undefined

From Dev

Base class is undefined error (C2504)

From Dev

Elasticsearch upgrade (2.4 to 5.0.1). Class cannot be resolved - indirect reference error

From Dev

c++ "Incomplete type not allowed" error accessing class reference information (Circular dependency with forward declaration)

From Dev

c++ "Incomplete type not allowed" error accessing class reference information (Circular dependency with forward declaration)

From Dev

implicit conversion from a class to any one of its direct or indirect base classes

From Dev

Array not allowed in class in C++/CLI?

From Dev

C++ pointer to incomplete class type is not allowed

From Dev

"Declaration Not allowed here" and "Constant Expression" Error in C

From Dev

Srand not an allowed function error in c++

From Dev

Inconsistent Accessibility base class error

From Dev

Error when using a member of a base class in a class nested within a template in C++

From Dev

Error when using a member of a base class in a class nested within a template in C++

From Dev

Indirect preprocessor substitution C

From Dev

Indirect preprocessor substitution C

From Dev

Jboss error: Only one JAX-RS Application Class allowed

From Dev

Error using glMultiDrawArraysIndirect and indirect buffer

From Dev

c++ - base class as property

From Dev

Base class of everything in c++

From Dev

base class implementation in C#

From Dev

C++ -- Assigning a derived class to a base class

From Dev

Upcasting derived class to base class in C#

From Dev

Why does calling this virtual function in C++ result in a 'missing symbol' error from the base class?

From Dev

Is mixing the old and new C++ function syntax in a class allowed?

From Dev

Intel C++ compiler (icpc 14.0): "a derived class is not allowed here"

From Dev

C++ incomplete type is not allowed class inner use?

Related Related

  1. 1

    C++ error: object of abstract class type is not allowed

  2. 2

    error C2504: base class undefined

  3. 3

    Error C2504 - Base class undefined

  4. 4

    Error C2504 - Base class undefined

  5. 5

    Base class is undefined error (C2504)

  6. 6

    Elasticsearch upgrade (2.4 to 5.0.1). Class cannot be resolved - indirect reference error

  7. 7

    c++ "Incomplete type not allowed" error accessing class reference information (Circular dependency with forward declaration)

  8. 8

    c++ "Incomplete type not allowed" error accessing class reference information (Circular dependency with forward declaration)

  9. 9

    implicit conversion from a class to any one of its direct or indirect base classes

  10. 10

    Array not allowed in class in C++/CLI?

  11. 11

    C++ pointer to incomplete class type is not allowed

  12. 12

    "Declaration Not allowed here" and "Constant Expression" Error in C

  13. 13

    Srand not an allowed function error in c++

  14. 14

    Inconsistent Accessibility base class error

  15. 15

    Error when using a member of a base class in a class nested within a template in C++

  16. 16

    Error when using a member of a base class in a class nested within a template in C++

  17. 17

    Indirect preprocessor substitution C

  18. 18

    Indirect preprocessor substitution C

  19. 19

    Jboss error: Only one JAX-RS Application Class allowed

  20. 20

    Error using glMultiDrawArraysIndirect and indirect buffer

  21. 21

    c++ - base class as property

  22. 22

    Base class of everything in c++

  23. 23

    base class implementation in C#

  24. 24

    C++ -- Assigning a derived class to a base class

  25. 25

    Upcasting derived class to base class in C#

  26. 26

    Why does calling this virtual function in C++ result in a 'missing symbol' error from the base class?

  27. 27

    Is mixing the old and new C++ function syntax in a class allowed?

  28. 28

    Intel C++ compiler (icpc 14.0): "a derived class is not allowed here"

  29. 29

    C++ incomplete type is not allowed class inner use?

HotTag

Archive