+ 4

Error while initializing a field (of base class) through constructors of derived classes.

Today, I'm revising multiple inheritance for my CS board exams and I've a code which has the following structure: A (base) |---B (derived) |---C (derived) Here is my code: https://code.sololearn.com/cmOdPHTM3y9R/#cpp In this, B uses member initializer list and C uses simple initialization. But, the initialization of B gives out an error: "error: class 'B' does not have any field named 'num'" I don't get why it says so, because both B and C publicly inherits public members of A. Please explain.

27th Mar 2019, 9:22 AM
777 - avatar
0 Answer