From owner-freebsd-questions Thu Dec 14 23:11:49 1995 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id XAA00160 for questions-outgoing; Thu, 14 Dec 1995 23:11:49 -0800 (PST) Received: from hp.com (hp.com [15.255.152.4]) by freefall.freebsd.org (8.7.3/8.7.3) with ESMTP id XAA00149 for ; Thu, 14 Dec 1995 23:11:45 -0800 (PST) Received: from hpautobo.aus.hp.com by hp.com with ESMTP (1.37.109.16/15.5+ECS 3.3) id AA107661496; Thu, 14 Dec 1995 23:11:38 -0800 Message-Id: <199512150711.AA107661496@hp.com> Received: by hpautobo.aus.hp.com (1.37.109.16/16.2) id AA127531494; Fri, 15 Dec 1995 18:11:34 +1100 From: M C Wong Subject: g++ 2.6.3 problem with temp object, fixed in 2.7 ? To: freebsd-questions@freefall.FreeBSD.org (freebsd-questions@freefall.cdrom.com) Date: Fri, 15 Dec 95 18:11:33 EDT Mailer: Elm [revision: 70.85] Sender: owner-questions@FreeBSD.ORG Precedence: bulk -----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 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-----