Open randomwangran opened 6 years ago
https://github.com/randomwangran/cpp/blob/5991dc7b44bb34ec1dea9f9b30e7cdf32f59a41b/learnCpp/Chapter9/9.x/9.x.3.cpp#L9-L10
You can give a default initialization value directly:
int m_length = 0; int *m_array = nullptr;
Those two pieces of code are essentially equal to each other because of what I wrote in my constructor:
IntArray(int size = 0) : m_size(size) { int *m_array = new int[m_size]; }
https://github.com/randomwangran/cpp/blob/5991dc7b44bb34ec1dea9f9b30e7cdf32f59a41b/learnCpp/Chapter9/9.x/9.x.3.cpp#L9-L10
You can give a default initialization value directly: