Compiler Warning (level 1) C4620
Collapse the table of content
Expand the table of content
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

Compiler Warning (level 1) C4620

Error Message

no postfix form of 'operator ++' found for type 'type', using prefix form

There is no postfix increment operator defined for the given type. The compiler used the overloaded prefix operator.

This warning can be avoided by defining a postfix ++ operator. Create a two-argument version of the ++ operator as shown here:

// C4620.cpp
// compile with: /W1
class A
   A(int nData) : m_nData(nData)

   A operator++()
      m_nData -= 1;
      return *this;

   // A operator++(int)
   // {
   //    A tmp = *this;
   //    m_nData -= 1;
   //    return tmp;
   // }

   int m_nData;

int main()
   A a(10);
   a++;   // C4620
© 2016 Microsoft