Confused between $cast and factory override

In reply to UVM_LOVE:

2.agent_a_h is created by agent_b not agent_a because type override.
after doing type override agent_a with agent_b, then while creating agtent_a object using create method actually it creates object for agent_b and returns handle of agent_b (note: this handled by UVM DB and factory override)
3. cast1 is the same as agent_b class’s agent_a_h_2 and agent_b class’s agent_a_h.
so they are same object type. no problem.
Yes…

cast2 = $cast(agent_b_h, agent_a_h); // This $cast won’t work without type override, why?
it won’t work because without override, agent_a_h variable contains the class handle(i.e. object instance memory location) for agent_a, so…agent_b_h and agent_a_h are different class types and hence it won’t work