Skip to content

Latest commit

 

History

History
50 lines (42 loc) · 970 Bytes

compiler-warning-level-1-c4620.md

File metadata and controls

50 lines (42 loc) · 970 Bytes
description title ms.date f1_keywords helpviewer_keywords ms.assetid
Learn more about: Compiler Warning (level 1) C4620
Compiler Warning (level 1) C4620
11/04/2016
C4620
C4620
fed29934-b797-47e8-bbea-c7e5f8dd6e93

Compiler Warning (level 1) C4620

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
{
public:
   A(int nData) : m_nData(nData)
   {
   }

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

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

private:
   int m_nData;
};

int main()
{
   A a(10);
   ++a;
   a++;   // C4620
}