This is a naive version of std::vector. Now consider what happens here:
1 2 3 4 5 6 7
int main() {
DynamicArray a(5); //let's say, a.data = 1234
DynamicArray b;
b = a; //a plain copy. now b.data = 1234 too
}//end of scope. b is destroyed -> it calls "delete 1234".
// a is destroyed -> it calls "delete 1234" too, but this produces a runtime error,
// since you can't delete a thing twice.
To fix this, you need the following copy constructor: