• Advertisement
Sign in to follow this  

class inhertance error

This topic is 4794 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

this is my code for a header file: #ifndef GLCANVAS_H #define GLCANVAS_H #include "PrecompiledHeaders.h" class GLCanvas : public wxGLCanvas { public: GLCanvas( wxWindow &frame, int &var, wxPoint &point, wxSize &size, DWORD &style, wxString &title ); }; #endif and i am getting this error: C:\Stromgage 3D Game Engine\Stromgage 3D Game Engine\GLCanvas.cpp(5) : error C2512: 'wxGLCanvas' : no appropriate default constructor available is there anyway i can make a class to take wxGLCanvas cuase the defualt way of make glcanvas is wxGLCanvas *MainGLCanvas = new wxGLCanvas( GameWindow, -1, wxPoint( 0, 0 ), wxSize( 800, 600 ), NULL, ""); and that line of code works in the game code.

Share this post


Link to post
Share on other sites
Advertisement
If your base class doesn't have a default constructor (remember, providing a custom constructor inhibits implicit generation of the default constructor), you must pass the appropriate parameters in your own class' constructor's initialization list:


class Foo
{
int m_i;
public:
Foo(int i) : m_i(i) {}
virtual ~Foo() {}
};

class Bar :
{
double m_d;
public:
Bar(int i, double d) : Foo(i), m_d(d) {}
};

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement