Compiler Error C2231

 

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 C2231.

left operand points to 'class-key', use '–>'

The operand to the left of the member-selection operation (.) is a pointer instead of a class, structure, or union.

The following sample generates C2231:

// C2231.c  
struct S {  
   int member;  
} s, *ps = &s;  
int main() {  
   ps.member = 0;   // C2231  
  
   // OK  
   ps->member = 0;   // crash  
   s.member = 0;  
}  

Show: