inheritance - public, private, protected?

Discussion in 'C++' started by Jordi, Jun 28, 2006.

  1. Jordi

    Jordi Guest

    I was wondering, in C++ the syntax for inheritance is basically this:
    class Descendant : public Parent {
    ....
    };

    Can someone tell me what would happen when I would replace 'public' by
    'private' or 'protected'? I've looked through some tutorials on
    inheritance, but the ones I found are mostly concerned with covering
    the basic idea and simply skip over this and take it for granted, so
    I'm hoping one of you can tell me.
    Jordi, Jun 28, 2006
    #1
    1. Advertising

  2. Jordi wrote:
    > I was wondering, in C++ the syntax for inheritance is basically this:
    > class Descendant : public Parent {
    > ...
    > };
    >
    > Can someone tell me what would happen when I would replace 'public' by
    > 'private' or 'protected'? I've looked through some tutorials on
    > inheritance, but the ones I found are mostly concerned with covering
    > the basic idea and simply skip over this and take it for granted, so
    > I'm hoping one of you can tell me.


    It's covered in the FAQ:

    http://www.parashift.com/c -faq-lite/private-inheritance.html

    Best regards,

    Tom
    Thomas Tutone, Jun 28, 2006
    #2
    1. Advertising

  3. Jordi

    Jordi Guest

    Yes, thank you, I was just on my way to deleting this.

    I'm new to these newsgroups, so I didn't know there was a FAQ... :$


    Thomas Tutone schreef:

    > Jordi wrote:
    > > I was wondering, in C++ the syntax for inheritance is basically this:
    > > class Descendant : public Parent {
    > > ...
    > > };
    > >
    > > Can someone tell me what would happen when I would replace 'public' by
    > > 'private' or 'protected'? I've looked through some tutorials on
    > > inheritance, but the ones I found are mostly concerned with covering
    > > the basic idea and simply skip over this and take it for granted, so
    > > I'm hoping one of you can tell me.

    >
    > It's covered in the FAQ:
    >
    > http://www.parashift.com/c -faq-lite/private-inheritance.html
    >
    > Best regards,
    >
    > Tom
    Jordi, Jun 28, 2006
    #3
  4. Jordi wrote:
    > Yes, thank you, I was just on my way to deleting this.
    >
    > I'm new to these newsgroups, so I didn't know there was a FAQ... :$


    My notes (since you're new): (a) don't top-post and (b) always assume
    that there is a FAQ list unless told otherwise (so, your first post
    to any newsgroup should be "where do I find the FAQ?" unless you know
    it already and have read it before posting), (c) do not treat any forum
    as a "write-only" medium, always spend time *reading* it before even
    thinking of posting.

    Good luck!

    > [...]


    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
    Victor Bazarov, Jun 28, 2006
    #4
  5. Jordi

    Jordi Guest

    Thank you for your kind and patient comments. I kind of assumed that
    the entire thread would disappear if I removed my message, because it
    was the one that started this topic...

    I have one last (probably totally stupid question):
    How do I not top-post? Am I always supposed to reply to the last person
    who posted in the thread, or always to the first?

    Victor Bazarov wrote:
    > Jordi wrote:
    > > Yes, thank you, I was just on my way to deleting this.
    > >
    > > I'm new to these newsgroups, so I didn't know there was a FAQ... :$

    >
    > My notes (since you're new): (a) don't top-post and (b) always assume
    > that there is a FAQ list unless told otherwise (so, your first post
    > to any newsgroup should be "where do I find the FAQ?" unless you know
    > it already and have read it before posting), (c) do not treat any forum
    > as a "write-only" medium, always spend time *reading* it before even
    > thinking of posting.
    >
    > Good luck!
    >
    > > [...]

    >
    > V
    > --
    > Please remove capital 'A's when replying by e-mail
    > I do not respond to top-posted replies, please don't ask
    Jordi, Jul 8, 2006
    #5
  6. Jordi

    Jerry Coffin Guest

    In article <>,
    says...

    [ ... ]

    > How do I not top-post? Am I always supposed to reply to the last person
    > who posted in the thread, or always to the first?


    Top-posting or otherwise isn't about which post you follow-up to.
    It's about where you write your comments. When you write your
    comments at the top of your post, followed by a quote of the post to
    which you're following up, that's a top-post.

    This post is at least an attempt at something closer to the
    recommended style. When you post a follow-up, start by trimming away
    all the quoted material that isn't directly relevant. Then write a
    comment immediately following the quoted bit to which it applies. If
    you want to comment on two or more parts, your comments get
    interleaved with the quotes to which they reply.

    If you can't find a relatively short bit to quote that really says
    what you're commenting on, it's perfectly reasonable to write your
    own summary of what you think they're saying. When you do this, you
    do need to make it clear that this is your summary though -- usually
    something like:

    [... code demonstrating partial specialization elided ]

    My comments on partial specialization go here...

    As far as which post to follow up to: follow up to the post you want
    to comment on, whether that's the first in the thread, the last, or
    somewhere else. The topic of a thread can drift, and in some cases
    sub-threads develop. Your comments might relate only distantly to
    original post or the most recent one, so it wouldn't make any sense
    to follow up to either of them.

    --
    Later,
    Jerry.

    The universe is a figment of its own imagination.
    Jerry Coffin, Jul 8, 2006
    #6
  7. Jordi

    Duane Hebert Guest

    "Jordi" <> wrote in message
    news:...
    > Thank you for your kind and patient comments. I kind of assumed that
    > the entire thread would disappear if I removed my message, because it
    > was the one that started this topic...
    >
    > I have one last (probably totally stupid question):
    > How do I not top-post? Am I always supposed to reply to the last person
    > who posted in the thread, or always to the first?


    Like this.
    Duane Hebert, Jul 8, 2006
    #7
    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. Shapper

    Public, Private, Protected? Thanks.

    Shapper, May 31, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    20,805
    clintonG
    May 31, 2005
  2. bigbinc
    Replies:
    7
    Views:
    37,956
    Dale King
    Sep 22, 2003
  3. Chris Mantoulidis
    Replies:
    6
    Views:
    627
    Grimble Gromble
    Jan 3, 2004
  4. qazmlp
    Replies:
    19
    Views:
    770
    Daniel T.
    Feb 4, 2004
  5. DaveLessnau
    Replies:
    3
    Views:
    412
    Howard
    May 16, 2005
Loading...

Share This Page