Some puzzles about sgistl!

Discussion in 'C++' started by Kevin Wan, Aug 16, 2003.

  1. Kevin Wan

    Kevin Wan Guest

    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!
    Kevin Wan, Aug 16, 2003
    #1
    1. Advertising

  2. "Kevin Wan" <> wrote...
    > 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
    Victor Bazarov, Aug 16, 2003
    #2
    1. Advertising

  3. 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.
    Gianni Mariani, Aug 16, 2003
    #3
  4. Kevin Wan

    Kevin Wan Guest

    "Victor Bazarov" <> wrote in message news:<pVs%a.157066$o%2.66713@sccrnsc02>...
    > "Kevin Wan" <> wrote...
    > > 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?

    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!
    >
    > > 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.


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

    Thank you very much!

    Kevin
    Kevin Wan, Aug 17, 2003
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. hezhang
    Replies:
    5
    Views:
    648
    hezhang
    Feb 16, 2006
  2. some C puzzles

    , Sep 1, 2004, in forum: C Programming
    Replies:
    10
    Views:
    812
    Dan Pop
    Sep 6, 2004
  3. xPy

    puzzles...puzzles...

    xPy, Feb 14, 2006, in forum: C++
    Replies:
    2
    Views:
    374
    Neil Cerutti
    Feb 14, 2006
  4. thomas

    some puzzles

    thomas, Feb 22, 2008, in forum: C++
    Replies:
    12
    Views:
    639
    Alf P. Steinbach
    Feb 23, 2008
  5. Oltmans

    Need some JavaScript puzzles

    Oltmans, Sep 23, 2008, in forum: Javascript
    Replies:
    27
    Views:
    315
    David Mark
    Nov 28, 2008
Loading...

Share This Page