This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: [G++] compilation error: difference between int and bool
- To: gcc-help at gcc dot gnu dot org
- Subject: Re: [G++] compilation error: difference between int and bool
- From: Florian Weimer <Florian dot Weimer at RUS dot Uni-Stuttgart dot DE>
- Date: 02 Jun 2001 21:10:46 +0200
- References: <20010602210446.A1044@cote-dazur.com>
noon@cote-dazur.com (Fabrice Bauzac) writes:
> Could anyone explain me why
>
> ==============================
> #include <vector>
>
> class T {
> vector <bool> v;
> bool &element (int i) { return v[i]; }
> };
> ==============================
>
> doesn't compile?
I'm not a C++ guru, but I think you cannot return a non-const
reference to a temporary object (and a temporary object is required
because bool and int are different types).
--
Florian Weimer Florian.Weimer@RUS.Uni-Stuttgart.DE
University of Stuttgart http://cert.uni-stuttgart.de/
RUS-CERT +49-711-685-5973/fax +49-711-685-5898