Compiler Error C2227

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at Compiler Error C2227.

left of '->member' must point to class/struct/union/generic type

The operand to the left of -> is not a pointer to a class, structure, or union.

The following sample generates C2227:

// C2227.cpp  
int *pInt;  
struct S {  
public:  
    int member;  
} s, *pS = &s;  
  
int main() {  
   pInt->member = 0;   // C2227 pInt points to an int  
   pS->member = 0;   // OK  
}  

Show: