This documentation is archived and is not being maintained.

Compiler Error C2355

'this' : can only be referenced inside non-static member functions

The this pointer is valid only within non-static member functions.

The following sample generates C2355:

// C2355.cpp
// compile with: /c
class MyClass {};
MyClass *p = this;   // C2355

// OK
class MyClass2 {
   void Test() {
      MyClass2 *p = this;