Predefined member functions and inheritance

L

lovecreatesbeauty

How many member functions will be predefined (provided by compilers
implicitly) and called by standard-compliant compilers for a class?
Does such a list be given in iso/iec 14882?

Which member functions of a base class won't be inherited by derived
class?

Do all the member functions of a base class predefined by
standard-compliant compilers won't be inherited by derived class? -
i.e., does the pre-definition mean non-inheritable?


Thank you
lovecreatesbeauty
 
B

ben

How many member functions will be predefined (provided by compilers
implicitly) and called by standard-compliant compilers for a class?

The compilers will synthesize the following members if one or more of such
functions are needed by not provided by the programmer:

-default constructor
-copy constructor
-destructor

Unless the aboved functions are tagged private, you can always assume that
an object of such class
-can be constructed
-can be copied
-and can be destroyed once it is contructed.
Does such a list be given in iso/iec 14882?

That I don't know.
Which member functions of a base class won't be inherited by derived
class?

All member functions are inherited by derived class. That said, however,
access control renders the private part of the base class invisible to the
derived class.
Do all the member functions of a base class predefined by
standard-compliant compilers won't be inherited by derived class? -
i.e., does the pre-definition mean non-inheritable?

Unless there are other "predefined" member functions I dont know of, the
answer is no.
 
L

lovecreatesbeauty

There should be a exact list of predefined member functions. Now I know
that total 7 member functions will be provided by compilers implicitly,
because:

Scott Meyers's `Effective C++ (2nd)' says in item 45 that 6 member
functions will be provided then called by standard-compliant compilers
for a class: (1)default constructor, (2)copy constructor,
(3)destructor, (4)assignment operator, (5)address-of operator
(non-const), (6)address-of operator (const).

The creator Dr. Bjarne Stroustrup mentioned one more in `TC++PL`,
section 11.2.2: operator, (comma operator)
 
H

Howard

lovecreatesbeauty said:
There should be a exact list of predefined member functions. Now I know
that total 7 member functions will be provided by compilers implicitly,
because:

Scott Meyers's `Effective C++ (2nd)' says in item 45 that 6 member
functions will be provided then called by standard-compliant compilers
for a class: (1)default constructor, (2)copy constructor,
(3)destructor, (4)assignment operator, (5)address-of operator
(non-const), (6)address-of operator (const).

You've stated that before, but it's not what he says. Where in that text
did you find anything about #s 5 and 6 (the const and non-const address-of
operators)?

-Howard
 

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

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,045
Latest member
DRCM

Latest Threads

Top