如果我是基类" Base"和派生类"派生"然后哪一个好吗?
<Error>
<Message>
No HTTP resource was found that matches the request URI 'http://example.com/api/admin/echo'.
</Message>
<MessageDetail>
No type was found that matches the controller named 'admin'.
</MessageDetail>
</Error>
(上面两行很好)
Base b = new Base();
Derived d = new Derived();
他们有意义吗?
答案 0 :(得分:1)
@ Zuzlx的评论是现场评论:
所有奶牛都是动物,但不是所有的奶牛都是奶牛。
将Base
替换为Animal
,将Derived
替换为Cow
,它将变得更加清晰:
Animal a = new Cow(); // This works since a cow is always an animal.
Cow c = new Animal(); // Just won't work.