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?
[code]
//Window class header
class VGLWindow
{
public:
VGLWindow();
~VGLWindow();
virtual bool Create(char*, short, short, short, short, uint, uint);
virtual uint ProcessMessage(uint, uint, long, long);
virtual void Destroy();

protected:
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
{
public:
VGLButton();
~VGLButton();

//Things only the button class should have go here
private:
};

//Button class code
bool VGLButton::Create(...)
{
//Do some more stuff
return true;
}
[/code]
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.

-[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]
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!

Categories