By the way, every time you are tempted to write new T[size]
, you should most likely use std::vector<T>
. By using local pointers to dynamic arrays, it is simply too difficult to ensure that memory is deallocated correctly in the event of an exception being thrown.
a source
to share