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,
lovecreatesbeau ty 2 2983
lovecreatesbeau ty 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
lovecreatesbeau ty 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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 similar to what I'm thinking about.
Lets suppose I make a class called RoleCollection.
|
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"
|
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 class Details : GeneratedDetails
{
|
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 class Details : GeneratedDetails
{
|
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 group. I think you
understand both C and C++ entirely, if not, why you still work on the C
programming language. And you are experts on both them, so it is not
off-topic at all. I need your help.
Please let us go into the topic.
I'm disturbed on...
| |
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 in question is
referring to static members of a class *from a subclass*.
(Now, I know for sure there's a similar difference, in that VB.NET
allows/ed you to invoke static members from an instance member, whereas
C# has always required you to...
|
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 called boxer? Just get
the Dog members from bulldog and leave out any inherited members from
Animal.
Dog bulldog=new Dog(); <-has inhereited members from Animal
|
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 is misleading!). The complete truth is that private members are not inherited.
I wish to restate the principle: "The access modifier 'private' is not just an access modifier. It also means that the member who has this modifier will not be...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |