lundi 26 mars 2018

Can I somehow trigger an "event" when a property changes?

I have a property class

class Prop
{
public:
   Prop(const std::string &key);

private:
   std::string Key;
   std::string Value;

public:
   void Prop::operator=(const std::string &value) 
   {
      this->Value = value;
   }
};

Then I have a user class

class User
{
public:
   User();

public:
   Prop Name;
};

So let's say I use it.

User user;
user.Name = "Suzie";

When I set the Name property, is there a way for the User object to know that a change was made to one of its Prop's?

Aucun commentaire:

Enregistrer un commentaire