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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With