When using operator overloading for prefix and postfix increment, I get an error from compiler:
"Fajl Fajl::operator ++(int)' : member function already defined or declared"
Here are my headers for operator ++:
Fajl& operator ++ (); // prefix
Fajl& operator -- (); // prefix
Fajl operator ++ (int); // postfix
Fajl operator ++ (int); // postfix
And my implementations:
Fajl& Fajl::operator ++ () // prefix
{
++(*poz);
return *this;
}
Fajl& Fajl::operator -- () // prefix
{
--(*poz);
return *this;
}
Fajl Fajl::operator ++ (int dummy) // postfix
{
Fajl temp(*this);
++(*this);
return temp;
}
Fajl Fajl::operator -- (int dummy) // postfix
{
Fajl temp(*this);
--(*this);
return temp;
}
"Fajl" is the class, and "poz" its argument which I'm incrementing. What am I doing wrong?
Fajl operator ++ (int); // postfix
Fajl operator ++ (int); // postfix
^^
should be --