This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
initialization of non-const reference
- To: gcc at gcc dot gnu dot org
- Subject: initialization of non-const reference
- From: Sjoerd Adema <sjoerd at axy dot nl>
- Date: Fri, 22 Sep 2000 16:55:11 +0200
- Organization: AXY Management Systemen
- Reply-To: sadema at axy dot nl
Hi,
I am in big trouble :-(
My databasesoftware contains the following code:
class genericObj {
...
public:
genericObj( ..., const SetObj& set );
...
};
class myObj : public genericObj {
...
public:
myObj() : genericObj(..., SetObj() ) {}
...
};
when I compile the sourcecode I get the compiler error: initialization
of non-const reference type `class SetObj &`
Bjarne Stroustrup tells in his book section 10.4.10 "A temporary can be
used as an initializer for a CONST reference or a named object."
Tons of code is written like this, so it is a huge problem for me.
Am I missing something here ? I use Suse Linux 6.4 with gcc 2.95-2
Any help would be highly appreciated.
Sjoerd Adema
AXY Management Systemen
The Netherlands
sadema@axy.nl