Skip to content

Commit 2c56428

Browse files
authored
Simplify redundant relative links in "Multiple Base Classes" topic
1 parent c98f946 commit 2c56428

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

‎docs/cpp/multiple-base-classes.md‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ When declaring a virtual base class, the **`virtual`** keyword appears in the ba
4141
4242
Consider the class hierarchy in the following figure, which illustrates a simulated lunch line:
4343
44-
:::image type="complex" source="../cpp/media/vc38xp1.gif" alt-text="Diagram of a simulated lunch line." border="false":::
44+
:::image type="complex" source="media/vc38xp1.gif" alt-text="Diagram of a simulated lunch line." border="false":::
4545
The base class is Queue. Cashier Queue and Lunch Queue both inherit from Queue. Finally, Lunch Cashier Queue inherits from both Cashier Queue and Lunch Queue.
4646
:::image-end:::
4747
*Simulated lunch-line graph*
4848
4949
In the figure, `Queue` is the base class for both `CashierQueue` and `LunchQueue`. However, when both classes are combined to form `LunchCashierQueue`, the following problem arises: the new class contains two subobjects of type `Queue`, one from `CashierQueue` and the other from `LunchQueue`. The following figure shows the conceptual memory layout (the actual memory layout might be optimized):
5050
51-
:::image type="complex" source="../cpp/media/vc38xp2.gif" alt-text="Diagram of a simulated lunch line object." border="false":::
51+
:::image type="complex" source="media/vc38xp2.gif" alt-text="Diagram of a simulated lunch line object." border="false":::
5252
The figure shows a Lunch Cashier Queue object with two subobjects in it: Cashier Queue and Lunch Queue. Both Cashier Queue and Lunch Queue contain a Queue subobject."
5353
:::image-end:::
5454
*Simulated lunch-line object*
@@ -66,21 +66,21 @@ class LunchCashierQueue : public LunchQueue, public CashierQueue {};
6666

6767
The **`virtual`** keyword ensures that only one copy of the subobject `Queue` is included (see the following figure).
6868

69-
:::image type="complex" source="../cpp/media/vc38xp3.gif" alt-text="Diagram of a simulated lunch line object, with virtual base classes depicted." border="false":::
69+
:::image type="complex" source="media/vc38xp3.gif" alt-text="Diagram of a simulated lunch line object, with virtual base classes depicted." border="false":::
7070
The diagram shows a Lunch Cashier Queue object, which contains a Cashier Queue subobject and a Lunch Queue subobject. Both Cashier Queue and Lunch Queue share the same Queue subobject.
7171
:::image-end:::
7272
*Simulated lunch-line object with virtual base classes*
7373

7474
A class can have both a virtual component and a nonvirtual component of a given type. This happens in the conditions illustrated in the following figure:
7575

76-
:::image type="complex" source="../cpp/media/vc38xp4.gif" alt-text="Diagram of virtual and non virtual components of a class." border="false":::
76+
:::image type="complex" source="media/vc38xp4.gif" alt-text="Diagram of virtual and non virtual components of a class." border="false":::
7777
The diagram shows a queue base class. A Cashier Queue class and Lunch Queue class inherit virtually from Queue. A third class, Takeout Queue, inherits non virtually from queue. Lunch Cashier Queue inherits from both Cashier Queue and Lunch Queue. Lunch Takeout Cashier Queue inherits from both Lunch Cashier Queue and Takeout Queue.
7878
:::image-end:::
7979
*Virtual and nonvirtual components of the same class*
8080

8181
In the figure, `CashierQueue` and `LunchQueue` use `Queue` as a virtual base class. However, `TakeoutQueue` specifies `Queue` as a base class, not a virtual base class. Therefore, `LunchTakeoutCashierQueue` has two subobjects of type `Queue`: one from the inheritance path that includes `LunchCashierQueue` and one from the path that includes `TakeoutQueue`. This is illustrated in the following figure.
8282

83-
:::image type="complex" source="../cpp/media/vc38xp5.gif" alt-text="Diagram of the object layout for virtual and non virtual inheritance." border="false":::
83+
:::image type="complex" source="media/vc38xp5.gif" alt-text="Diagram of the object layout for virtual and non virtual inheritance." border="false":::
8484
A Lunch Takeout Cashier Queue object is shown that contains two subobjects: a Takeout Queue (which contains a Queue subobject) and a Lunch Cashier Queue. The Lunch Cashier Queue subobject contains a Cashier Queue subobject and a Lunch Queue subobject, both of which share a Queue sub object.
8585
:::image-end:::
8686
*Object layout with virtual and nonvirtual inheritance*
@@ -141,7 +141,7 @@ The compiler detects ambiguities by performing tests in this order:
141141

142142
1. If overloaded functions are unambiguous, they're resolved.
143143

144-
1. If access to the name violates member-access permission, an error message is generated. For more information, see [Member-Access Control](../cpp/member-access-control-cpp.md).
144+
1. If access to the name violates member-access permission, an error message is generated. For more information, see [Member-Access Control](member-access-control-cpp.md).
145145

146146
When an expression produces an ambiguity through inheritance, you can manually resolve it by qualifying the name in question with its class name. To make the preceding example compile properly with no ambiguities, use code such as:
147147

@@ -191,7 +191,7 @@ Explicit and implicit conversions from pointers or references to class types can
191191
192192
- The effect of explicitly converting the pointer obtained using the address-of operator to the base-class type `A`. Coercing the address of the object to type `A*` doesn't always provide the compiler with enough information as to which subobject of type `A` to select; in this case, two subobjects exist.
193193
194-
:::image type="complex" source="../cpp/media/vc38xt1.gif" alt-text="Diagram showing how the conversion of pointers to base classes can be ambiguous." border="false":::
194+
:::image type="complex" source="media/vc38xt1.gif" alt-text="Diagram showing how the conversion of pointers to base classes can be ambiguous." border="false":::
195195
The diagram first shows an inheritance hierarchy: A is the base class. B and C inherit from A. D inherits from B and C. Then, the memory layout is shown for object D. There are three subobjects in D: B (which includes a subobject A) and C (which includes a subobject A). The code & d points to the A in subobject B. The code ( * A ) & d points to both subobject B and subobject C.
196196
:::image-end:::
197197
*Ambiguous conversion of pointers to base classes*
@@ -209,7 +209,7 @@ If virtual base classes are used, functions, objects, types, and enumerators can
209209

210210
The following figure shows how objects are composed using virtual and nonvirtual inheritance.
211211

212-
:::image type="complex" source="../cpp/media/vc38xr1.gif" alt-text="Diagram showing virtual derivation and nonvirtual derivation." border="false":::
212+
:::image type="complex" source="media/vc38xr1.gif" alt-text="Diagram showing virtual derivation and nonvirtual derivation." border="false":::
213213
The diagram first shows an inheritance hierarchy: A is the base class. B and C virtually inherit from A. D virtually inherits from B and C. Then, the layout of D is shown. D contains subobjects B and C, which share subobject A. Then the layout is shown as though the same hierarchy had been derived using nonvirtual inheritance. In that case, D contains the subobjects B and C. Both B and C contain their own copy of subobject A.
214214
:::image-end:::
215215
*Virtual and nonvirtual derivation*
@@ -218,4 +218,4 @@ In the figure, accessing any member of class `A` through nonvirtual base classes
218218

219219
## See also
220220

221-
[Inheritance](../cpp/inheritance-cpp.md)
221+
[Inheritance](inheritance-cpp.md)

0 commit comments

Comments
 (0)