以前はこれを行うことができ、意図したとおりに機能していたことを思い出します。
class foobar
{
public:
foobar(int x, int y)
{
x = x; //the variables x, y belonging to the class got correctly initialized
y = y;
}
private:
int x, y;
};
上記は、Microsoft Visual C++ 6.0 以降のいくつかのバージョンで 200x 前後で動作したと思います。
しかし、今は Microsoft Studio 2013 でこれを行う必要があり、次this->
のように使用する必要があります。
class foobar
{
public:
foobar(int x, int y)
{
this->x = x; //the other way no longer initializes class vars
this->y = y;
}
private:
int x, y;
};
言語仕様の変更または Microsoft コンパイラの変更はありましたか?