Yes malloc is a solution but I prefer to avoid pointers in C++ because they increase the probability of errors.
No. The use of pointers does not increase the probability of errors. The misuse of pointers, on the other hand, does. Learning to properly use pointers is not a waste of time and effort.