|
-
January 31st, 2010, 04:17 AM
#1
inheritance or include ?
Hello,
Im facing a conception problem in my program. I have a statics library (all methods are static, no data member) and I would like to use these methods but I would like to know if I should inherit from this class or an simple include will do ?
I have to use the static library in different class, Ive been told to inherit virtually to have one instance of the library used.
Could you guys give me your opinion ?
Thank you for help
-
January 31st, 2010, 05:59 AM
#2
Re: inheritance or include ?
If your "library" has only static methods, what does it mean to have an "instance" of that class?
As far as I know, just include your class, and use it.
You can publicly inherit from it if you want to expand the class to give it more methods, but when it comes down to using it, just include and call it.
-
January 31st, 2010, 06:27 AM
#3
Re: inheritance or include ?
 Originally Posted by sw21
I have a statics library (all methods are static, no data member)
You could consider turning it into a namespace of free functions instead.
-
January 31st, 2010, 07:09 AM
#4
Re: inheritance or include ?
 Originally Posted by monarch_dodra
If your "library" has only static methods, what does it mean to have an "instance" of that class?
As far as I know, just include your class, and use it.
You can publicly inherit from it if you want to expand the class to give it more methods, but when it comes down to using it, just include and call it.
That is what I think as well. How to be sure it is better ? is there any book where this case is covered, with a typical excample ? it is for a professional use, I have to be sure of what I do.
Thank you anyway for your answers
-
January 31st, 2010, 07:34 AM
#5
Re: inheritance or include ?
 Originally Posted by sw21
That is what I think as well. How to be sure it is better ? is there any book where this case is covered, with a typical excample ? it is for a professional use, I have to be sure of what I do.
Thank you anyway for your answers
"Static" or dynamic aside
If you don't include a header file then you won't be able to use it!
Anyone claiming that he can should be crackers.
Also, calling static methods crops up different issues
-
January 31st, 2010, 08:09 AM
#6
Re: inheritance or include ?
Nice explanation, but is it a free library ? You mind if I ask for sharing ?
Sig-na-tju-(r)
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
|