Question

1.
2.
3.
4.
Answer (Detailed Solution Below)

Option 1 : B, then C, then D / B, फिर C, फिर D

Advertisement

Detailed Solution

सही उत्तर B, then C, then D / B, फिर C, फिर D है।

Key Points
Helpful?
PrepSnapprepsnap.in • Part -A

Question:

In C++ multiple inheritance, for the declaration class D : public B, public C { ... }; D obj; the order in which constructors execute is ___ / C++ मल्टीपल इनहेरिटेंस में, घोषणा class D : public B, public C { ... }; D obj; हेतु कंस्ट्रक्टरों के निष्पादन का क्रम ___ है

1.
B, then C, then D / B, फिर C, फिर D
2.
D, then B, then C / D, फिर B, फिर C
3.
C, then B, then D / C, फिर B, फिर D
4.
D, then C, then B / D, फिर C, फिर B

Correct Answer: B, then C, then D / B, फिर C, फिर D

Base-class constructors run before the derived-class constructor, in the order the bases appear in the declaration list: B first, then C, then D. Destructors run in the reverse order. / व्युत्पन्न-क्लास कंस्ट्रक्टर से पहले बेस-क्लास कंस्ट्रक्टर चलते हैं, घोषणा सूची में बेसों के दिखने के क्रम में: पहले B, फिर C, फिर D। डिस्ट्रक्टर उल्टे क्रम में चलते हैं।

Downloaded from PrepSnap (prepsnap.in)