Date: Fri, 15 Dec 95 18:11:33 EDT From: M C Wong <mcw@hpato.aus.hp.com> To: freebsd-questions@freefall.FreeBSD.org (freebsd-questions@freefall.cdrom.com) Subject: g++ 2.6.3 problem with temp object, fixed in 2.7 ? Message-ID: <199512150711.AA107661496@hp.com>
next in thread | raw e-mail | index | archive | help
-----BEGIN PGP SIGNED MESSAGE-----
Hi,
When compiling the following program, I got error :
lespoir:/local/home/wongm 107 > g++ -o doo doo.cc
doo.cc: In function `int ctor()':
doo.cc:27: request for member `foo' in `myBar(Foo)', which is of non-aggregate type `Bar ()(Foo)'
doo.cc:29: no matching function for call to `Bar::Bar (Bar ()(Foo))'
doo.cc:15: candidates are: Bar::Bar(const Foo &)
doo.cc:16: Bar::Bar(Bar &)
doo.cc:29: in base initialization for class `Bar'
It seems that gcc does not think of myBar is an object, 8-((
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include <stream.h>
class Foo
{
public:
Foo(int) { };
~Foo() {} ;
void bar( ) { cout << "bar called" << endl; } ;
};
class Bar
{
public:
Bar(const Foo&) {};
Bar(Bar&) {};
~Bar() {};
void foo( ) { cout << "foo called" << endl; };
};
const int myInt = 7;
int ctor()
{
Bar myBar(Foo(myInt));
// myBar.foo( );
// Bar yourBar( Bar &myBar = Bar( Foo( myInt ) ) ); /* works */
Bar yourBar( myBar );
// Bar yourBar(Bar(Foo(myInt))); /* works */
yourBar.foo( );
return 0;
}
main( )
{
ctor( );
}
~
- --
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
M.C Wong Email: mcw@hpato.aus.hp.com
Australian Telecom Operation Voice: +61 3 9210 5568
Hewlett-Packard Australia Ltd Fax: +61 3 9210 5550
P.O. Box 221, Blackburn 3130, Australia OS: FreeBSD-1.1.5.1
http://www-ato.aus.hp.com/~mcw
-----BEGIN PGP SIGNATURE-----
Version: 2.6.2i
iQCVAwUBMNEfoEmThh0X7Um5AQEqOQP/bd2IlVRsDO2r14DZI9GKaB6P/2CyFW6g
YAs3D/3RHc08gf79vx3OFQfWPczvyMSE+XbicGZILVF3qR63UmTd6JP7w/mQ8XxR
07BkvVidZvtca0rBc60l6FQ6vWf9N/mOzNPWvxYEiaD8OHuwlo9gldShudZCTj2K
rLtlDiTFog8=
=pqTz
-----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199512150711.AA107661496>
