Path: utzoo!attcan!uunet!cs.utexas.edu!ut-emx!nowhere!sking From: sking@nowhere.uucp (Steven King) Newsgroups: comp.lang.c++ Subject: Re: operator++() and testing 'this' Message-ID: <1990Oct14.224706.1934@nowhere.uucp> Date: 14 Oct 90 22:47:06 GMT Organization: nowhere Lines: 34 In article <1990Oct9.144542.19983@sco.COM> jfischer@sco.COM (Jonathan A. Fischer) writes: >In article <706@msor0.UUCP> kt@msor.UUCP (Keith Tizzard) writes: >>Two questions about C++ >> >>2 Testing of and assigning to 'this' >> >>Is it still possible to assign to 'this' in V2.0? > > Technically, you can't assign to this, since it's "X * const this". >BUT, it's listed in Appendix B.3.3 as an "anachronism," something that is >provided for compatibility with earlier releases of cfront. I.e., you can do >it, but technically you shouldn't. Also, there is no requirement for a >compiler vendor to implement these anachronisms, so you are tainting your >portability by using them. > >>Can one rely on 'this' having the value zero on entry to the constructor >>if the object is allocated on the free store? > > Yep, according to the same anachronisms section. And only if the object isnt a member (or base) of another object. Even tho' the translator knows this information (it does pass a flag to destructors) there is NOT a reliable mechanism to determine this from within a constructor. I wonder if there is enough of a need for this to consider adding it to the language... -- ------------------------------------------------------------------------------- new && improved: sking@nowhere old && reliable: ...!cs.utexas.edu!ut-emx!nowhere!sking -------------------------------------------------------------------------------