Call constructor/destructor of base class

A

Alf P. Steinbach

* Karl Heinz Buchegger:
Alf P. Steinbach said:
* Karl Heinz Buchegger:
:

* Karl Heinz Buchegger:
:

There are numerous such places in the standard. But to avoid any
misunderstanding, let me first state categorically that this does _not_
mean I think "otherwise" re your example above. Let me repeat that: it
does not mean that I, or the standard, thinks "otherwise" re your example
above. Wrt. your example above you have correct understanding. Now (if
that's OK?) see e.g. §12.1/5, "a default constructor for a class X is a
constructor of class X that can be called without without an argument".

That doesn't answer my question, since it doesn't say how I (the programmer)
have to code a call to a constructor. It merly says: It can be called, eg.
during the process of creating an object, a constructor may be called.

You ignore the part of that very short quote which was the reason I
carefully selected it for you.

It says the default constructor can be called _without an argument_, and
that is necessarily a source code explicit call:

How come?

You happily snipped the explanation, here it is again:

<quote>
[the phrasing "without an argument"] does not make sense in
generated code, which must supply any arguments in the argument
list.
</quote>

It seems you have a habit of not seeing things you don't like.

Note: the word "explicit" means the opposite of "implicit".
If the object construction is done without arguments the compiler
can use the default constructor. That's all the above is saying.

No, it says, quote: "can be called without an argument".

But it doesn't say by whom.

It does; see above. Note in particular that "without any argument" can
not refer to a generated call. So it must refer to a source code call.

(In fact that's the point of that particular paragraph: if you
provide default values for all arguments of a constructor, then
it becomes a default constructor because then it "can be called
without an argument" in the source code; the paragraph is simply
a definition of what a default constructor is, based on how it can
be called in the source code.)

And that is the whole point!!!!!!!!

"Multiple explanation marks are a true sign of a diseased mind"
(Terry Pratchett) ;)
 
K

Karl Heinz Buchegger

I am getting tired of your ignorance.
The standard clearly states: there is no way to explicitely call a constructor.
I leave it with that and bail out.
 
A

Alf P. Steinbach

* Karl Heinz Buchegger:
I am getting tired of your ignorance.
Liar.


The standard clearly states: there is no way to explicitely call a constructor.

It does not.

It does on the other hand state numerous places that you can call them,
and I've given you one such reference.

It does that because you can.
 
S

SaltPeter

Alf P. Steinbach said:
* Karl Heinz Buchegger: constructor.

It does not.

It does on the other hand state numerous places that you can call them,
and I've given you one such reference.

It does that because you can.

There is a huge difference between calling a member function and invoking a
cstor or d~stor.

Its neccessary that a coder understands the difference between constructing
an object and calling, say, one of a couple of overloaded functions, for
example. Imagine a classA object that provides a default constructor and a
ClassA(int) constructor, not to mention a copy constructor. Regardless of
which constructor is invoked, the resulting instance is identical in type.
This result can't be said of a couple of overloaded member functions. The 2
member functions represent unique behaviours and unique signatures.

The question isn't what the standard says, consider multple constructors
employed to create the exact same type of object. While a derived class can
hide or modify a base class's virtual functions, it can't replace or modify
the base class's constructor(s). Thats because the derived class can't call
the base class's constructor(s), it can only invoke them.
 

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,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top