// each object maintains a pointer 'this' to itself; // explicit or implicit use of 'this'; // 'this' pointer refers to object members; // type of 'this' pointer depends on the type of object AND whether the // member function in which 'this' is used is declared 'const'; // in a non-constant member function of a class A, 'this' pointer has type // A * const (a constant to an A object); // in a constant member function of class A, 'this' pointer has type // A const * const (a constant pointer to a constant A type) #include class test { public: test(int = 0); // default constructor void print() const; private: int x; }; test::test(int a) {x = a;} // constructor, add if (x == 0) and run. // if the class has the constructor, has // the default constructor been called? void test::print() const { // type of 'this': const * const, see above cout << " x = " << x << "\n this-> = " << this->x << "\n(*this).x = " << (*this).x << '\n'; } main( ) { test a(12); a.print(); getchar(); return 0; }