Class is not tracking changes to a private field
It is all about calling conventions and argument binding. The code is using call-by-value when it should be call-by-reference. 

This is call-by-value (the incoming command is not updated, a copy is passed as parameter):

void Widget::init(Command _command)
...
widget.init(command);


This is call-by-reference (a pointer to command is passed as parameter):

void Widget::init(Command* _command)
{
   __command-&gt;registerDevice(...);
}
...
widget.init(&amp;command);


Alternative syntax is:

void Widget::init(Command&amp; _command)
{
   _command.registerDevice(...);
}
...
widget.init(command)


Cheers!