Why I can’t define a static field in the declaration?
You can!
#include <string>
class MyClass
{
static inline std::string name = "Whatever";
// ^^^^^^
};
Isn’t name private by default? Then why can I change its value from outside the class?
You can’t!
You’re defining/initialising it, not changing its value.
CLICK HERE to find out more related problems solutions.