I think it would help if you provided a concrete code example. For example, this is valid in C++11+:
Code:
class X
{
public:
int get() const
{
return n;
}
private:
int n = 123;
};
It is not valid pre-C++11. If you need to be compatible with compiling with respect to pre-C++11, you would write:
Code:
class X
{
public:
X() : n(123) {}
int get() const
{
return n;
}
private:
int n;
};
The above of course works in C++11+ too. So, what exactly is the problem that you are facing?
EDIT:
Oh, reading your post again, my guess is that you did this:
Code:
class X
{
public:
X()
{
int n = 123;
}
int get() const
{
return n;
}
};
This is an error in standard C++, regardless of which edition of the standard. It is an error because n is declared as a non-static local variable of the constructor, so its scope and hence its lifetime is limited to the scope of the constructor (not the lifetime of the object). Therefore, you cannot refer to n in the get member function because n has not been declared in that scope. This error is entirely due to a mistake on your part; it is has nothing to do with changes introduced in C++11.