Article View: comp.std.c++
Article #815Re: Calling constructors for parms passed by value
From: Tilo Levante
Date: Tue, 05 Feb 1991 07:36
Date: Tue, 05 Feb 1991 07:36
39 lines
1173 bytes
1173 bytes
The g++, tc++, ... compilers are correct. You missed the
(default) copy constructor. If you write your program this way,
you will see it:
#include<stream.h>
class bug {
public:
bug() { cout << "in constructor\n"; }
bug(const bug& a) { cout << "in copy constructor\n"; }
~bug() { cout << "in destructor\n"; }
};
foo(bug a, bug b)
{
cout << "in foo\n";
}
main()
{
bug a,b;
foo(a,b);
}
The output is:
in constructor
in constructor
in copy constructor
in copy constructor
in foo
in destructor
in destructor
in destructor
in destructor
I assume that cfront has a bug in this case. It has to
destruct the value parameters.
Tilo
Technical Details
Message-ID:
<1991Feb5.073657.6030@bernina.ethz.ch>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!snorkelwacker.mit.edu!bloom-beacon!eru!hagbard!sunic!mcsun!cernvax!chx400!bernina!tiloReferences:
<631@necssd.NEC.COM>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!snorkelwacker.mit.edu!bloom-beacon!eru!hagbard!sunic!mcsun!cernvax!chx400!bernina!tilo From: tilo@bernina.ethz.ch (Tilo Levante) Newsgroups: comp.std.c++ Subject: Re: Calling constructors for parms passed by value Message-ID: <1991Feb5.073657.6030@bernina.ethz.ch> Date: 5 Feb 91 07:36:57 GMT References: <631@necssd.NEC.COM> Organization: Swiss Federal Institute of Technology (ETH), Zurich Lines: 39