Encapsulate a feature based on a shared object in c++