Here's what I ended up doing. @wohlstad said "you can encapsulate a single boolean parameter (with current and previous values) in a class" and that gave me the idea to do this:
class MemorableVar {
public:
MemorableVar() {
x = false;
prev_x = false;
};
// Setters:
void set(bool x0) {prev_x = x; x = x0;};
// Getters:
bool get() {return x;};
bool get_prev() {return prev_x;};
bool changed() {return (x != prev_x);};
private:
bool x;
bool prev_x;
};
In this approach, you use setters to control the variable value, and the previous value is remembered every time you do so.