|
-
September 24th, 2011, 07:52 AM
#1
Inherintance or Variable
Hello,
I'm writing a win32 class wrapper for fun and I've got a situation where I'm not sure what to do. I'll show a little bit code for example
Code:
class Window : public base // Base is a class where the HWND is stored and Hide() function etc
{
// stuff
}
class Button : public base // same as bove
{
// stuff
}
This code is all in the library
Now when I use my lib I'm making a class where window is public. The problem I've is should I make a variable of Button or should I make button public for the window class like this:
Code:
class Window : public base, public button
{
// stuff
}
class myclass : public Window
{
// stuff
}
else I've to do to in myclass this, Button * button1;
Now I only showed the button class, but what if I also use a listview,editbox, etc classes. If I included them all in Window class it will be huge. Should I do this or not? Also does the compiler leave out the code which the class do not need. For instance when myclass only the use the button class from Window, the rest got inculded to?
Thanks for reading,
Gz
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|