I wonder if it can be understood like this:
Because the scope of extern is the whole project and it is public, this variable can be used in class B without instantiation. Because a is not instantiated, AccountBalance is unknown to class B, so of course it can't be written like this. As for the solution, I think you will know when you understand the principle.