I'm learning C++ by following the tutorials and testing the code in MS Visual Studio 2013. The following codes that are at the end of the Classes (I) section has error:
In particular, it's this line:
baz = new Rectangle { {2,5}, {3,6} };
It seems that this could mean:
1. Pass an array with two components {2,5} and {3,6} into the Constructor
2. Call the constructor with one variable {x,y} with x={2,5} and y={3,6}
Could someone shed some light on this?
Thanks,
Yang
// pointer to classes example
#include <iostream>
using namespace std;
class Rectangle {
int width, height;
public:
Rectangle(int x, int y) : width(x), height(y) {}
int area(void) { return width * height; }
};