什么是父类的子类和派生的基类的VB.NET或C#的区别? [英] What is the difference between a child of a parent class and the derived of a base class in VB.NET or C#?

查看:387

的和的孩子的更抽象的关系。它们被用来描述层次结构,从而可以在各种树木被使用(或有时DAG)的。结果
类继承的树就是这样的树,所以称他们的孩子的没有错。结果
这个术语通常与其他种类的树木,比如嵌套GUI控件,目录结构,...

$ b使用
$ b

派生的仅用于继承,从而更精确。这个术语是首选,因为它是那么模糊。


After asking the question Call a method that requires a derived class instance typed as base class in VB.NET or C# on Stack Overflow, I was informed that I had used the wrong terms when asking the question. I had used "parent" and "child" where I should have used "base" and "derived" instead.

I have been unable to find a good description of the difference.

This is what I know (or think I know) so far:

A parent class contains the child class. Where as a derived class inherits from a base class.

They are similar because the child (or derived) can access the parents (or base) properties and methods (where allowed).

They are different because you can refer to a property of the child class in the form of Parent.Child.Property. Whereas you cannot do that with a derived class.

What is the difference and in what situation should one be used over the other?

解决方案

parent and child are more abstract relations. They are used to describe hierarchy, and thus can be used in all kinds of trees (or sometimes DAGs).
The tree of class inheritance is one such tree, so calling them parent and child is not wrong.
This terminology is often used with other kinds of trees, such as nested GUI controls, directory structures,...

base and derived is used only for inheritance, and thus more precise. This terminology is preferred, since it's less ambiguous.

这篇关于什么是父类的子类和派生的基类的VB.NET或C#的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆