Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.c++.moderated    |    Moderated discussion of C++ superhackery    |    33,346 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 33,219 of 33,346    |
|    Daryle Walker to All    |
|    Re: why does the 'this' pointer need mod    |
|    29 Sep 13 19:22:29    |
   
   From: darylew@googlemail.com   
      
   { Please limit your text to fit within 80 columns, preferably around 70,   
    so that readers don't have to scroll horizontally to read each line.   
    This article has been reformatted manually by the moderator. -mod }   
      
   Inside the definition of a non-static member function, you can refer to   
   the object currently in play with:   
      
    MyClass cv * const this = /* The current object's address */;   
      
   Where "cv" is the const and/or volatile status you added to the head of   
   the function. You cannot change the value of "this," but you can alter   
   the object it points to (or its sub-objects) if "cv" doesn't include   
   "const," and/or the computer can change the (sub-)object(s) behind your   
   back if "cv" includes "volatile."   
      
   Referring to non-static member data within the method will add "cv" to   
   its qualification before you can mess with it. If the data member is a   
   reference, the qualification is applied to the type behind the   
   reference. For pointers, the pointer as itself is qualified, but what   
   it points to doesn't change its qualification.   
      
   If you call a non-static member function, you're restricted to the ones with   
   the same qualification or harsher. For example, a "const" method cannot   
   call a bare method, but it can call other "const" methods or "const volatile"   
   methods. You can get around this by messing with "const_cast."   
      
   Daryle W.   
      
      
   --   
    [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
    [ comp.lang.c++.moderated. First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca