Inside a class definition you can supply a default initialization value which will be used on construction of an instance provided a relevant constructor doesn't specify its own initialization value, but that is not what you are doing here.
1 2 3 4 5 6 7 8
class Test
{
public:
void a(int);
private:
SDL_Rect* base = nullptr; // provide a default initialization value.
};
Hmm...So, prior to c++11, you could only initialize a static const member in the class declaration.
That's been relaxed significantly since c++11.
However, what you are doing here is different.
It's recommended that you initialize the "base" pointer in the constructor(s) for Test. After that, you should move the expression base->x = 9 to the constructor.
Ok, I get what is meant by putting the pointer initialization in the constructor. However, what is it that I am trying to do here that is illegal? Initializing member variables of an object via a pointer?