Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!hplabs!hpl-opus!hpnmdla!hpmwtd!jeffa From: jeffa@hpmwtd.HP.COM (Jeff Aguilera) Newsgroups: comp.lang.c++ Subject: Re: function modifiers Message-ID: <1520013@hpmwjaa.HP.COM> Date: 10 Jan 90 22:40:20 GMT References: <14940@robin.cs.nott.ac.uk> Organization: HP Microwave Tech. - Santa Rosa, Ca. Lines: 46 > In the code for the NIH library, there are several declarations of the > following form: > > const Object* Object::method() const; > > and also: > > friend const Object* Object::method() const; > > I've tried to compile this with g++-1.36.2 and discovered that friends > aren't allowed to have function modifiers in g++ i.e the terminating const. > Looking at the gnu manual, it seems that the use of the terminating const > (see 6.12) supposedly has a meaning unique to g++, yet must be legal syntax > for AT&T 2.0 since the library is written for that compiler. > > Removing the terminating const causes lots of other related error messages > to do with const member functions calling non-const member functions etc. > Unfortunately, we don't have AT&T C++ or a reference manual, so I'm unsure > of the precise effect the use of const. > > Could someone clarify this for me please and perhaps clear up the differences > between AT&T and G++ ? > > Alan Shepherd > ---------- Within a non-static member function of a class X, this implicitly has one of four types: X *const const X *const volatile X *const volatile const X *const //like boiling ice That is, this cannot be modified (it's a *const), and *this is an X, const X, volatile X, or volatile const X. An X can be promoted to a const X, but not the conversely. Your problem with const friends can probably be circumvented by delegating broader access rights: friend class Object; If gnu doesn't compile the const member function, you're up a creek. ----- jeffa