Compiler Error C2819
TOC
Collapse the table of content
Expand the table of content
This documentation is archived and is not being maintained.

Compiler Error C2819

Error Message

type 'type' does not have an overloaded member 'operator ->'

You need to define operator->() to use this pointer operation.

The following sample generates C2819:

// C2819.cpp
// compile with: /c
class A {
   public:
      int i;
};

class B {};

void C(B j) {
   j->i;   // C2819
}

class D {
   A* pA;

   public:
      A* operator->() {
         return pA;
      }
};

void F(D j) {
   j->i;
}

C2819 can also occur when using C++ Stack Semantics for Reference Types. The following sample generates C2819:

// C2819_b.cpp
// compile with: /clr
ref struct R {
   void Test() {}
};

int main() {
   R r;
   r->Test();   // C2819
   r.Test();   // OK
}
Show:
© 2016 Microsoft