Compiler Warning (level 1) C4621
no postfix form of 'operator --' found for type 'type', using prefix form
There was no postfix decrement 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 below:
// C4621.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--; // C4621
}
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for