Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!gem.mps.ohio-state.edu!ginosko!uunet!mcsun!unido!mez!frei From: frei@mez.e-technik.uni-bochum.de (Matthias Frei) Newsgroups: comp.lang.c++ Subject: Re: C++ 2.0 Question -- Whats wrong with this code ?? Message-ID: <297@mez.e-technik.uni-bochum.de> Date: 19 Oct 89 08:06:18 GMT References: <981@odin.SGI.COM> Organization: Ruhr Universitaet Bochum, W-Germany Lines: 26 mtoy@sgi.com (Michael Toy) writes: >1 class Base { >2 public: >3 BaseClass(); >4 }; >5 extern TakesOne(BaseClass*&); ... >10 TakesOne(this); >11 } >This causes C++2.0 to tell me "reference to const object" on line 10 Well, "this" is a const pointer to an object. If you pass "this" to TakesOne() is a reference, it could be manipulated outside of the class base, possibly leading to inconsistencies. You can avoid it by declaring extern TakesOne(const BaseClass* &) -- Matthias Frei | Snail-mail: | Microelectronics Center frei@mez.e-technik.uni-bochum.de | University of Bochum, W-Germany frei%rubmez@unido.BITNET | D-4630 Bochum, P.O.-Box 102143