In reply to Subhra Bera:
I understand the access control of class variables in terms of local, protected and public.
Actually, my question was a bit different. This is in terms of allowing class variables assignation between base and derived classes.
It is legal to assign an object of derived class to a base class variable. The reason normally given is that all that is there in the base class is also in the derived class.
You can see the following examples where using real world examples, they explain this but do not mention that there are cases where it is fatal to assign derived class object to base class variable.
https://www.quora.com/Why-can-a-base-class-reference-variable-refer-to-a-derived-class-object-in-Java
http://www.learncpp.com/cpp-tutorial/121-pointers-and-references-to-the-base-class-of-derived-objects/