Special implementation of composite pattern on C++