How to get size c++ dynamic array

“How to get size of dynamic array in functions? Because it seems the passing size of array n in every function is the wrong way.”

Yet it is the only way when you use dynamically allocated C-style array.

If you want to avoid sending the size explicitly then pass some object that wraps this raw memory buffer and provides other means of retrieving the size. The most reasonable solution here would be using std::vector<Airplane>.

Leave a Comment