Yes, that's fine.

You should consider using std::vector rather than using dynamic arrays directly. It will make your code cleaner.