PaulS:
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.
For every line you must type, there is a change you will mistype it or forget to do it. Thus, since you must declare the pointer, allocate memory from it, and free the memory (I guess that's technically optional on a uC) as opposed to just defining the object, you have the opportunity to make more errors with pointers.
I also consider it better design to use templates rather than malloc when possible.