Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
OOPS 中的向上转换通过覆盖父类和子类的方法使运行时多态成为可能。OOPS 中的向下转换也可以以任何方式运行时多态吗?
运行时多态性是通过继承实现的——向上转换和向下转换与它无关(尽管它们也只能通过继承实现)。
向下转换通常需要运行时多态性,因为向下转换可能会根据运行时类型成功或失败。