I have a question that may have been answered more than 9000 times, but I really don’t know how to say this, that’s what I’m going to try.
In some books and C ++ textbooks, I saw that when defining your own class that has semantics of iterative value (increment), you can overload operator++for it (everything that I am going to say here, I would assume it applies to operator--). The standard way to do this is as follows:
class MyClass {
public:
MyClass& operator++ () {
increment_somehow();
return *this;
}
....
};
Where increment_somehow()well ... somehow increases the value of the object.
You can then define the postfix version operator++as follows:
MyClass operator++ (MyClass& it, int dummy) {
MyClass copy(it);
++it;
return copy;
}
( , ), , , , operator++, , , , . , <utility> rel_ops, ( ++ ...):
class MyClass {
public:
bool operator== (const MyClass& that) {
return compare_for_equality_somehow(that);
}
bool operator< (const MyClass& that) {
return compare_for_lessality_somehow(that);
}
....
using namespace std::rel_ops;
};
( "" , - ...)
<step_ops.hpp>, std::rel_ops, Utility. Fro, , (TM). / ? , , using namespace MyLibrary::increment_operators ()?
, , , : , , ? , ++, , , boost::do_something, , .