I had a quiz at school and there was this question that I wasn't sure if I answered correctly. I could not find the answer in the book so I just wanted to ask you.
Point* array[10];
How many instances of class Point are created when the above code is called?
I answered none because it only creates space for 10 instances, but doesn't create any. Then my friend said it was just one because when the compiler sees Point* it just creates one instance as a base.
It creates no Point
s.
What it does is creates an array of ten pointers that can point to Point
objects (it doesn't create space for ten instances). The pointers in the array are uninitialized, though, and no Point
objects are actually created.