Subclassing and declarations...

SephirothSephiroth Fayetteville, NC, USA
I have a few questions about subclassing and declaring methods. I am creating an OpenGL windowing library for Windows and Linux, allowing users to easily create menus and such for games and applications with minimal code for the actual target OS. My problem though, comes in when subclassing and the subclass does not need to have as many arguments to a method as the primary class, and whether or not I even have to declare inherited methods in the class definition or simply rewrite the code dealing with said methods.

For example, would the situation below work, or would I have to declare the "Create" method in the button class header?
//Window class header
class VGLWindow
virtual bool Create(char*, short, short, short, short, uint, uint);
virtual uint ProcessMessage(uint, uint, long, long);
virtual void Destroy();

short X, Y, Width, Height;
uint ID, ParentID, Style;

//Window class code
bool VGLWindow::Create(...)
//Do some stuff
return true;

//Button class header
class VGLButton : VGLWindow

//Things only the button class should have go here

//Button class code
bool VGLButton::Create(...)
//Do some more stuff
return true;
Thanks for the info. My goal here is to allow users under Linux or Windows to simply create an instance of the main class, and call functions like "CreateWindow" and "DestroyWindow" with the same parameters on Windows and Linux, and not have to deal with a ton of portability issues or code definition blocks.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!