Because base
is constructed first and hasn’t “matured” into a derived
yet. It can’t call methods on an object when it can’t guarantee that the object is already properly initialized.
More Related Contents:
- Will an ’empty’ constructor or destructor do the same thing as the generated one?
- When should you use a class vs a struct in C++?
- Why is there no call to the constructor? [duplicate]
- What is the difference between private and protected members of C++ classes?
- Separating class code into a header and cpp file
- What are the differences between struct and class in C++?
- no default constructor exists for class
- How do you create a static class in C++?
- Is passing a C++ object into its own constructor legal?
- Error: cannot bind non-const lvalue reference of type ‘int&’ to an rvalue of type ‘int’
- How do you use the non-default constructor for a member?
- How does virtual method invocation work in C++?
- C++ inherit from multiple base classes with the same virtual function name
- What is the difference between a concrete class and an abstract class?
- Semicolon after class declaration braces
- sizeof class with int , function, virtual function in C++?
- How to add constructors/destructors to an unnamed class?
- Different ways of initializing an object in c++
- No matching function for call to Class Constructor
- Class inherited from class without default constructor
- Making a vector of instances of different subclasses
- What is the purpose of forward declaration?
- Why should I prefer to use member initializer lists?
- C++ Member Initializer List
- Scope resolution operator being used twice
- Scope of variables in if statements
- Can class template constructors have a redundant template parameter list in c++20
- Diamond Inheritance Lowest Base Class Constructor
- What is the order of evaluation in a member initializer list?
- Should objects delete themselves in C++?