在类结构中,"is a"和"has a"的不同点
2012-12-04 10:02
288 查看
is a:代表类之间的继承关系。比如PC机是计算机,工作站也是计算机。PC机和工作站是两种不同类型的计算机,但都继承了计算机的共同点特性。因此,在用Java语言实现时,应该将PC机和工作站定义成两种类,均继承计算机类。
has a:代表对象和它的成员的从属关系。同一种类的对象,通过它们的属性的不同值来区别。比如一台PC机的操作系统是Windows,另一台PC机的操作系统是Linux。操作系统是PC机的一个成员变量,根据这一成员变量的不同值可以区分不同的PC机对象。
has a:代表对象和它的成员的从属关系。同一种类的对象,通过它们的属性的不同值来区别。比如一台PC机的操作系统是Windows,另一台PC机的操作系统是Linux。操作系统是PC机的一个成员变量,根据这一成员变量的不同值可以区分不同的PC机对象。
相关文章推荐
- "is a"关系和"has a"关系
- Android JS桥交互("Uncaught ReferenceError: xxx is not defined or xxx has no method")
- 通过 composition模拟 "has-a"或 "is-implemented-in-terms-of"
- The connection to adb is down, and a severe error has occured."错误总结
- "The connection to adb is down, and a severe error has occured."亲测有用的方法
- eclipse运行android项目出现"The connection to adb is down, and a severe error has occured."的问题
- A requirement that almost every single application has is "I want to scale up an ImageView proportio
- eclipse运行android项目出现"The connection to adb is down, and a severe error has occured."的问题
- "The connection to adb is down, and a severe error has occured"错误解决方法
- [翻译] Effective C++, 3rd Edition, Item 38: 通过 composition(复合)模拟 "has-a"(有一个)或 "is-implemented-in-terms-of"(是根据……实现的)
- 条款38:通过复合塑膜出has-a或"根据某物实现"
- "Is-a"与"Has-a"
- PRB: "Troubleshooting Orphaned Users" Topic in Books Online is Incomplete
- ognl.OgnlException: target is null for setProperty(null, "y", [Ljava.lang.St
- 【Vegas原创】ORA-01103:"database name *** in control file is not @@@" 解决
- QWidget::setLayout: Attempting to set QLayout "" on MainWindow "", which already has a layout
- -canOpenURL: failed for URL: "weixin://app/wxff569f1617559XX1/" - error: "This app is not allowed to
- The path "/usr/src/linux/include" is not an existing directory.解决方式
- ognl.OgnlException: target is null for setProperty(null, "goodsSize", [Ljava.lang.String;@c3bb5。
- Error: Program "/ndk-build.cmd" is not found in PATH