Perhaps I misunderstood, but if you're struggling with proper declaration of both operators, you can still do this with free operators like members. You do, however, need to pass the object as the first parameter by-reference. You're correct that as member functions they get their object for free via this. As a free function, you need to push it yourself.
#include <iostream>
struct my_array
{
// your members here.
};
my_array& operator ++(my_array& obj)
{
// access to members is through obj.member
std::cout << "++obj called." << std::endl;
return obj;
}
my_array operator ++(my_array& obj, int)
{
my_array prev = obj;
// modify obj, but return the previous state.
std::cout << "obj++ called." << std::endl;
return prev;
}
int main(int argc, char *argv[])
{
my_array obj;
++obj;
obj++;
return 0;
}
Output
++obj called.
obj++ called.