473,378 Members | 1,383 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,378 software developers and data experts.

Which members are created automatically, which members are not inherited?

I'm disturbed on this question on a long time. I think if I finally get
understand it with your kind help, I will get close to a excellent C++
programmer. And I only can rely on your expertise and help. I've read
some books, but no book focuses on this. Don't you think it is a very
important thing of C++ programming language? So your knowledge is of
great benefit to others, especially me.
1. Which (How many) members will be created automatically?

Scott Meyers seems to give this list in a early print of his
<<effective C++, 2nd>>, but he removed 1 (or 2, perhaps you know it),
the list containing 6 members he gives is:

default constructor, copy constructor, destructor, assignment
operator, a pair of address-of operators (i.e. const, non-const) .

But in a later print (not a new edition, I don't read the 3rd one) he
removed the last pair of operators from that list without a detail
description, or he put that pair in that list before without a
thoroughly convinced reason. That is my complaint.

Dr. Bjarne Stroustrup mentioned operator , (i.e. comma) is also a
predefined member (he mentioned total 3: =, &, and , in TC++PL sec
11.2.2), but Andrew Koenig said "That is not a member function." in my
post before. Obviously, it is inside a class body, so I do not
understand what he said.

Herb Sutter mentioned &&, || and , (comma) in his new book C++ coding
standard. But he did not give a complete list of automatically created
class members also. He always talks about some magic things on usage of
vector, list or some similar things with gurus. That is my complaint.

How about new and delete, and some others functions or operators which
I do not know the name. Who will give a complete list?
2. Which (How many) members can not be inherited?

I know default ctor, copy ctor, dctor, assignment operator can not be
inherited. The first three members share the same name respectively
even the base class name and the derived class name are different - it
is obvious, but it helps me to understand the reason of non-inherited.
I can understand operator assignment will not be inherited also.

But I am not sure if there are other members also can not be inherited.

How about new and delete, and some others functions or operators which
I do not know the name. Who will give a complete list?
Sincerely,

lovecreatesbeauty

Jan 26 '06 #1
2 2953
lovecreatesbeauty wrote:
I'm disturbed on this question on a long time. I think if I finally get
understand it with your kind help, I will get close to a excellent C++
programmer. And I only can rely on your expertise and help. I've read
some books, but no book focuses on this. Don't you think it is a very
important thing of C++ programming language? So your knowledge is of
great benefit to others, especially me.
1. Which (How many) members will be created automatically?

Scott Meyers seems to give this list in a early print of his
<<effective C++, 2nd>>, but he removed 1 (or 2, perhaps you know it),
Why don't you "know it"? Doesn't your nearby library have both books?
the list containing 6 members he gives is:

default constructor, copy constructor, destructor, assignment
operator, a pair of address-of operators (i.e. const, non-const) .

But in a later print (not a new edition, I don't read the 3rd one) he
removed the last pair of operators from that list without a detail
description, or he put that pair in that list before without a
thoroughly convinced reason. That is my complaint.
You should contact Scott, then. If it's a complaint, I mean. You know,
Scott is available on Internet...
Dr. Bjarne Stroustrup mentioned operator , (i.e. comma) is also a
predefined member (he mentioned total 3: =, &, and , in TC++PL sec
11.2.2), but Andrew Koenig said "That is not a member function." in my
post before. Obviously, it is inside a class body, so I do not
understand what he said.
What _who_ said? Koenig or Stroustrup?
Herb Sutter mentioned &&, || and , (comma) in his new book C++ coding
standard. But he did not give a complete list of automatically created
class members also. He always talks about some magic things on usage of
vector, list or some similar things with gurus. That is my complaint.

How about new and delete, and some others functions or operators which
I do not know the name. Who will give a complete list?
The complete list is conditional. For example, if you have any
parameterised c-tor, the default c-tor is not generated. Assignment op
is not generated if there are members that don't allow that...
2. Which (How many) members can not be inherited?

I know default ctor, copy ctor, dctor, assignment operator can not be
inherited. The first three members share the same name respectively
even the base class name and the derived class name are different - it
is obvious, but it helps me to understand the reason of non-inherited.
I can understand operator assignment will not be inherited also.
No constructors are inherited. Ever.

Virtualness of the destructor is an inherited trait.

The _copy_ assignment op is not inherited. Parameterized can be.
But I am not sure if there are other members also can not be inherited.

How about new and delete, and some others functions or operators which
I do not know the name. Who will give a complete list?


I don't think there is a complete and hard-set list. It's all relative.

V
Jan 26 '06 #2
TB
lovecreatesbeauty sade:
I'm disturbed on this question on a long time. I think if I finally get
understand it with your kind help, I will get close to a excellent C++
programmer. And I only can rely on your expertise and help. I've read
some books, but no book focuses on this. Don't you think it is a very
important thing of C++ programming language? So your knowledge is of
great benefit to others, especially me.


<snipped Scott Meyers>
<snipped Bjarne Stroustrup>
<snipped Andrew Koenig>
<snipped Herb Sutter>

Why not enter the next level and buy a copy of the standard?
ISBN: 0470846747
That way you won't need to flip through several books to
find hidden hints/answers about language features, just one.

--
TB @ SWEDEN
Jan 26 '06 #3

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

Similar topics

6
by: thechaosengine | last post by:
Hi all, Is there a way to hide a member in a subclass that has been inherited from a base class? Lets leave aside any issues regarding whether its a good idea for a moment. Here's an example...
8
by: Franz Steinhaeusler | last post by:
Hello NG, I want to retrieve the members of a class with a baseclass. But the problem is, how to get the non derived members. class a: def who(self): print "who"
4
by: rob bowley | last post by:
I have a class which inherits from a generated abstract base class. I simply want to hide some fields which are inherited from the base class when it is serialised. I have tried: public...
6
by: rob.bowley | last post by:
I have a class which inherits from a generated abstract base class. I simply want to hide some fields which are inherited from the base class when it is serialised. I have tried: public...
43
by: lovecreatesbeauty | last post by:
Perhaps all C++ programmers are busy in designing their classes or get into a deep sleep after a through night hard work. So I am willing to ask the "off-topic" (perhaps not) question in this...
8
by: Larry Lard | last post by:
Today I discovered that a syntax that I thought was forbidden in C# but allowed in VB.NET (and I _don't like_ that it's allowed in VB.NET) is actually allowed in C#. Which confused me. The syntax...
2
by: eggie5 | last post by:
Hi, I have a class Dog which derives from Animal. Suppose my instance of Dog is bulldog. bulldog has all the members of Animal plus Dog. How can copy just the members from Dog to a new Dog...
9
by: ghd | last post by:
Beginners beware! Usually in lessons on inheritance, we learn that when a class extends another, the former inherits all the members of the latter. This statement is only partly true (in fact it...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.