Is it possible to relate two variable to be changed together?
Example:
class foo{
public:
std::vector<int> v1;
std::vector<float> v2;
//Imaginary Code here:
void on_v2_change(){
std::transform(begin(v2),end(v2),begin(v1),[](auto& item){ return std::round(item);});
}
}
int main(){
foo bar;
bar.v2.push_back(5.7);
//v2={5.4}
//v1={5}
}
Is there a straightforward way to implement the previous? something like Java or C# events.
Aucun commentaire:
Enregistrer un commentaire