Dynamic Array Exercise in C++