inheritance - public, private, protected?

J

Jordi

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

Thomas Tutone

Jordi said:
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
 
J

Jordi

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:
 
V

Victor Bazarov

Jordi said:
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
 
J

Jordi

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 said:
Jordi said:
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
 
J

Jerry Coffin

[ ... ]
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.
 
D

Duane Hebert

Jordi said:
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.
 

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

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top