Don’t do Java bean properties in C++

The reason why Java has the bean API is to ensure that the caller does not delete the object when setting it.

void setX(String val){

if (val == null) return;

this.x = val;

}

This is not necessary in C++, since the parent object owns the memory of the child object.  The equivalent C++ code would be simple

o.x = val;

If you want to do validation (see my earlier posts about regex validation) use a subclass that does the validation in its constructor and assignment operator.