Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!brutus.cs.uiuc.edu!zweig From: zweig@brutus.cs.uiuc.edu (Johnny Zweig) Newsgroups: comp.lang.c++ Subject: Re: 'this' question Message-ID: <1989Sep12.010035.3886@brutus.cs.uiuc.edu> Date: 12 Sep 89 01:00:35 GMT References: <14232@polyslo.CalPoly.EDU> <6590244@hplsla.HP.COM> Sender: news@brutus.cs.uiuc.edu Reply-To: zweig@cs.uiuc.edu Organization: U of Illinois, CS Dept., Systems Research Group Lines: 22 >//> Wang: >//> When I write: >//> >//> type_student* me = new type_student(); >//> >//> Is the address of 'me' guaranteed to be the same as the value of 'this' >//> for the 'me' object? Guaranteed not to be. &me would be the address of the pointer me. The VALUE stored in me has to be the same as the address of the type_student object, for example: type_student::f( type_student * p ) { printf("%x %x\n", this, p ); } will print the same number twice if you were to call me->f( me );. "this" is defined as a pointer to the object -- I imagine it would break a lot of code if somehow a pointer to object X and X.this couldn't be compared with == sensibly. -Johnny this