Skip to content

Commit e0ca07a

Browse files
ZJUGuoShuaiColin Robertson
authored and
Colin Robertson
committed
Update single-inheritance.md (MicrosoftDocs#214)
The original code doesn't demonstrate "Pointers and references to derived classes can be implicitly converted to pointers and references to their base classes if there is an accessible, unambiguous base class". The new code can show that.
1 parent 0db63b2 commit e0ca07a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

docs/cpp/single-inheritance.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,10 @@ class PaperbackBook : public Document {};
140140
141141
int main() {
142142
Document * DocLib[10]; // Library of ten documents.
143-
for (int i = 0 ; i < 10 ; i++)
143+
for (int i = 0 ; i < 5 ; i++)
144144
DocLib[i] = new Document;
145+
for (int i = 5 ; i < 10 ; i++)
146+
DocLib[i] = new PaperbackBook;
145147
}
146148
```
147149

0 commit comments

Comments
 (0)