In reply to prasham98:
When executing the statement
b1 = d1;, you are copying the handle to the derived class object stored in the class variable d1 to the class variable b1. The handle to the base class object that was in b1 is lost, and now both b1 and d1 reference the same derived class object.
When you print d1.a and d1.a, you are printing the same class member.