Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 2nd, 2012  |  syntax: None  |  size: 0.34 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. address of this
  2. #include <iostream>
  3. using namespace std;
  4. class Base
  5. {
  6.     public:
  7.         void test()
  8.         {
  9.             void *address_of_this =&this;
  10.             cout<<address_of_this<<endl;
  11.         }
  12. };
  13.  
  14. int main()
  15. {   Base k;
  16.     k.test();
  17.  
  18.     return 0;
  19. }   //error non-lvalue in unary'&'
  20.        
  21. std::cout << this;
  22.        
  23. void* a = this;