I made a operator overloading function in a class. And I made another function which recalls the overloading function in the class.
I want to use the function which recalls the operation overloading function in main function so I wrote like this in the main function :
#include <iostream> ... class Zealot { int x; .... void operator++() { Zealot s; s.x = -50; for (auto i = 0; i < 2; ++i, tail.push_back(s)); } void Collision() { ... (*this)++; // Error : C2676 ... } ... }; Zealot z; int main() { z.Coliision(); } I got Error C2676 so I couldn't compile the source.
What should I do to work it well? I need your big helps.
++, so you'd invoke it like++(*this);. The postfix form is distinguished by a parameter (that's otherwise unused) of typeint, so it's:void operator++(int). Note thatoperator++()should normally return a reference to the just-incremented object.