Skip to content

Commit 868e4e2

Browse files
authored
[spec/class] Improve super class docs (#3671)
* [spec/class] Improve super class docs Move *Super Class* section above *Fields*, which has an example using inheritance. Add simple example. Add note about multiple inheritance/interfaces. * A super class must come before interfaces
1 parent b3cd652 commit 868e4e2

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

spec/class.dd

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ $(P A class consists of:)
5050

5151
$(COMMENT list of notable components, not exhaustive)
5252
$(UL
53-
$(LI a super class)
53+
$(LI a $(RELATIVE_LINK2 super_class, super class))
5454
$(LI $(DDLINK spec/interface, Interfaces, interfaces)
5555
$(LI dynamic fields)
5656
$(LI $(DDSUBLINK spec/attribute, static, static) fields)
@@ -100,6 +100,25 @@ $(H2 $(LNAME2 access_control, Access Control))
100100
The default visibility attribute is $(D public).
101101
)
102102

103+
$(H2 $(LNAME2 super_class, Super Class))
104+
105+
$(P
106+
All classes inherit from a super class. If one is not specified,
107+
a class inherits from $(REF1 Object, object). `Object` forms the root
108+
of the D class inheritance hierarchy.
109+
)
110+
111+
---
112+
class A { } // A inherits from Object
113+
class B : A { } // B inherits from A
114+
---
115+
116+
$(P Multiple class inheritance is not supported, however a class can inherit from
117+
multiple $(DDLINK spec/interface, Interfaces, interfaces).
118+
If a super class is declared, it must come before any interfaces.
119+
Commas are used to separate inherited types.)
120+
121+
103122
$(H2 $(LNAME2 fields, Fields))
104123

105124
$(P Class members are always accessed with the `.` operator.
@@ -215,12 +234,6 @@ $(H3 $(LNAME2 hidden-fields, Accessing Hidden Fields))
215234
should not be used in user code.
216235
)
217236

218-
$(H2 $(LNAME2 super_class, Super Class))
219-
220-
All classes inherit from a super class. If one is not specified,
221-
it inherits from $(REF1 Object, object). `Object` forms the root
222-
of the D class inheritance hierarchy.
223-
224237
$(H2 $(LNAME2 member-functions, Member Functions (a.k.a. Methods)))
225238

226239
$(P Non-static member functions have an extra hidden parameter

0 commit comments

Comments
 (0)