Path: utzoo!attcan!uunet!aplcen!uakari.primate.wisc.edu!zaphod.mps.ohio-state.edu!swrinde!ucsd!ucbvax!hplabs!hpda!hpcupt1!thomasw From: thomasw@hpcupt1.HP.COM (Thomas Wang) Newsgroups: comp.lang.c++ Subject: Re: testing this==0 Message-ID: <7050021@hpcupt1.HP.COM> Date: 27 Jun 90 01:13:15 GMT References: <1990Jun26.175953.16763@uncecs.edu> Organization: Hewlett Packard, Cupertino Lines: 30 / hpcupt1:comp.lang.c++ / harris@uncecs.edu (Mark Harris) / 10:59 am Jun 26, 1990 / >#include >struct test{ > int a; > test(){ > if(this==0)puts("zero"); > else puts("nonzero"); > } >}; Testing or setting 'this' to 0 should not be done any more. This is what I use for testing heap versus stack objects: // explain function // Is this object allocated from the stack? // This code is machine dependent. It assumes stack have a higher address // than heap space. char base_ref_t::is_stack_object() { char x; return ((unsigned int) this) > ((unsigned int) &x); } > Mark Harris mail:harris@ecsvax(UUCP/BITNET) -Thomas Wang (Everything is an object.) wang@hpdmsjlm.cup.hp.com thomasw@hpcupt1.cup.hp.com