// 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";
}
質問> VS2010でCase A、Case Bともに問題なくコンパイルできます。
元のケース A のみが機能すると仮定します。これは、デフォルトのパラメーターは、関数の定義の場所ではなく、関数が宣言されている場所に導入する必要があることを覚えているためです。誰かがこれについて私を修正できますか?
ありがとうございました