// Case A
class Point {
private:
int x;
int y;
public:
Point(int i = 0, int j = 0); // Constructor
};
Point::Point(int i, int j) {
x = i;
y = j;
cout << "Constructor called";
}
// Case B:
class Point {
private:
int x;
int y;
public:
Point(int i, int j); // Constructor
};
Point::Point(int i = 0, int j = 0) {
x = i;
y = j;
cout << "Constructor called";
}
Question> Both Case A and Case B compile without problems with VS2010.
Original I assume only Case A works because I remember that the default parameters should be introduced in the place where the function is declared rather than the location of its definition. Can someone correct me on this?
Thank you