473,387 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

inheritance - public, private, protected?

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.

Jun 28 '06 #1
6 4621
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-lit...heritance.html

Best regards,

Tom

Jun 28 '06 #2
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-lit...heritance.html

Best regards,

Tom


Jun 28 '06 #3
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
Jun 28 '06 #4
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
Jul 8 '06 #5
In article <11**********************@p79g2000cwp.googlegroups .com>,
jb*****@gmail.com 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.
Jul 8 '06 #6

"Jordi" <jb*****@gmail.comwrote in message
news:11**********************@p79g2000cwp.googlegr oups.com...
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.
Jul 8 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Screwball | last post by:
<?php class myClass { var $myVar; .. .. } ?> In php.ini I have error_reporting = E_ALL | E_STRICT
6
by: Chris Mantoulidis | last post by:
Forgive me if I'm wrong but I think there is something like an extra member scope in classes. for example: class abc { ostream & operator << (ostream &, const abc &); istream & operator >>...
3
by: seesaw | last post by:
Compared to "public", how does "private/protected" in inheritance change relationship between classes what is the purpose to define constructor as "private/protected"? is there any usage to...
3
by: Mark A. Gibbs | last post by:
Good day, i'm having a bit of trouble with a base class i'm working on. this is what it boils down to: template <typename T> class foo { protected: foo() { T* p = static_cast<T*>(this); }
3
by: Shapper | last post by:
Hello, What is the difference of using: Sub function() Public Sub function() Private Sub function() Protected Sub function() I place all my functions in my aspx.vb files but I have some...
4
by: newbie120 | last post by:
Hi all maybe its just been a long day, but i have a question about call access modifiers in C#. Consider the following code. namespace Application { private class Class1 { int i;
9
by: Kenneth Porter | last post by:
I'm un-indenting the constructs mentioned in the subject line to align with the enclosing braces: switch (expression) { case 1: statement1; case 2; statement2; default:
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.