Some puzzles about sgistl!

K

Kevin Wan

Hi,

I have some puzzles about sgistl source code, that is why some methods
are placed in protected field.

To vector itself, private and protected are the same, and vector isn't
desired to be the base class of other containers.

So why not use private instead of protected?

Anyone can explain it for me?

Thanks in advance!
 
V

Victor Bazarov

Kevin Wan said:
I have some puzzles about sgistl source code, that is why some methods
are placed in protected field.

To vector itself, private and protected are the same, and vector isn't
desired to be the base class of other containers.

Why isn't it?
So why not use private instead of protected?

If you can answer why I couldn't inherit from vector, then I will
probably agree that private is better.
Anyone can explain it for me?

As soon as you can explain why you think vector shouldn't be a base
class. Please do not give the old "no virtual destructor" spiel
because I am not going to delete my derived class polymorphically.

Victor
 
G

Gianni Mariani

Victor Bazarov wrote:
....
As soon as you can explain why you think vector shouldn't be a base
class. Please do not give the old "no virtual destructor" spiel
because I am not going to delete my derived class polymorphically.

I don't mean to open old wounds and add lemon juice but I need to know
if the concensus is that this is now a DEAD topic. I really don't want
to start another flameola. I hope I can now create derivable classes
with impunity without virtual destructors and not have the virtual
destructor police knocking down my door.
 
K

Kevin Wan

Victor Bazarov said:
Why isn't it?
I remember Scott Meyers told that never publicly inherit from a class
which has no virtual destructor. You can make sure you'll not use it
polymorphically, but you can't force your client not to use it
polymorphically!

And if you use private or protected inheritance, the useful public
methods need to be re-written, as you know, the inherited methods
aren't public! I think it's a boring task!
If you can answer why I couldn't inherit from vector, then I will
probably agree that private is better.


As soon as you can explain why you think vector shouldn't be a base
class. Please do not give the old "no virtual destructor" spiel
because I am not going to delete my derived class polymorphically.

Would you please show me your ideas about what I metioned above?

Thank you very much!

Kevin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top