Chapter 6:Inheritance and Composition
2005-02-25 17:23
459 查看
Insect { i = 9; j; Insect() { prt( + i + + j); j = 39; } x1 = prt(); prt(String s) { System.out.println(s); 47; } } Beetle Insect { k = prt(); Beetle() { prt( + k); prt( + j); } x2 = prt(); prt(String s) { System.out.println(s); 63; } main(String[] args) { prt(); Beetle b = Beetle(); } }
该程序的输出如下:
Insect.x initialized Beetle.x initialized Beetle constructor i = 9, j = 0 Beetle.k initialized k = 63 j = 39
相关文章推荐
- scala - composition and inheritance
- thinking in java(V)--composition and inheritance
- How to use composition and inheritance in visual c# ?
- Multiple Inheritance in Java and Composition vs Inheritance
- Thinking in Java(6)-combinning composition and inheritance
- Inheritance & Composition(Chapter 14 of Thinking in C++)
- Java-Choose between Composition and Inheritance
- The Anatomy of a COM Server(Chapter 2 of COM and .NET Interoperability) part2
- COM Type Information(Chapter 4 of COM and .NET Interoperability)
- CLR Via C# 3rd 阅读摘要 -- Chapter 14 - Chars, Strings, and Working with Text
- Operator overload and inheritance
- Chapter 2 - Types, Operators and Expressions(四)
- C++: virtual inheritance and Cross Delegation
- Public Private Protect Inheritance and access specifiers
- Chapter 1 Securing Your Server and Network(6):为SQL Server访问配置防火墙
- Chapter 4 - Functions and Program Structure(五)
- 继承(inheritance),组合(composition),聚合(aggregation)
- Data Structures (Weiss) Chapter 8: Union and Find, Disjoint Sets, union by sizes, C++
- Handbook of Constraints Programming——Chapter 22 Constraint-Based Scheduling and Planning
- Professional C# 6 and .NET Core 1.0 - Chapter 43 WebHooks and SignalR