dynamic memory allocation in c++ example