Looking at example under “Pointers to classes” (very bottom)
How is it that we can use the dot operatior here:
CRectangle * d = new CRectangle[2];
...
d[1].set_values (7,8);
if d is a pointer?
Same question for the lines:
cout << "d[0] area: " << d[0].area() << endl;
cout << "d[1] area: " << d[1].area() << endl;
Also, For the declaration:
CRectangle * d = new CRectangle[2];
We can just declare a pointer to the type without declaring an object first?
d is a pointer to an array of CRectangle objects (2 in this case). d[i] is the i’th CRectangle object. so when you say d[i].set_values(), you are really calling the set_values method on the i’th CRectangle object in that array.