C++ class that makes it possible to reuse previouse used memory