Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Call constructor/destructor of base class

Reply
Thread Tools

Call constructor/destructor of base class

 
 
Alf P. Steinbach
Guest
Posts: n/a
 
      07-07-2004
* Karl Heinz Buchegger:
> "Alf P. Steinbach" wrote:
> >
> > * Karl Heinz Buchegger:
> > > "Alf P. Steinbach" wrote:
> > > >
> > > > * Karl Heinz Buchegger:
> > > > > "Alf P. Steinbach" wrote:
> > > > > >
> > > > > > 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)

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
 
Reply With Quote
 
 
 
 
Karl Heinz Buchegger
Guest
Posts: n/a
 
      07-07-2004
"Alf P. Steinbach" wrote:
>


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.

--
Karl Heinz Buchegger
http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
 
 
 
Alf P. Steinbach
Guest
Posts: n/a
 
      07-07-2004
* Karl Heinz Buchegger:
> "Alf P. Steinbach" wrote:
> >

> 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.


> I leave it with that and bail out.


--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
 
Reply With Quote
 
SaltPeter
Guest
Posts: n/a
 
      07-11-2004

"Alf P. Steinbach" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> * Karl Heinz Buchegger:
> > "Alf P. Steinbach" wrote:
> > >

> > 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.
>
>


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.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Base class method Need base class value Karan Rajput Ruby 2 12-22-2010 04:47 PM
base class public type (non template and template base class) Hicham Mouline C++ 1 04-20-2009 03:28 PM
derived class incresing the sopce of base class methods and explicit call to constructor Taran C++ 6 04-20-2006 06:26 PM
Access of base class' private base class: qualification required, why Alf P. Steinbach C++ 6 09-03-2005 04:03 PM
Overload by deriv class param; call w base class param ectoplasm C++ 12 07-28-2005 08:20 AM



Advertisments