#include <iostream>
using namespace std;
class A{
public:
A(){
cout << "A ";
}
A(int a){
cout << "PA ";
}
};
class B{
public:
B(){
cout << "B ";
}
B(int a){
cout << "PB ";
}
};
class C: public A, public B {
public:
C():B(),A(){
cout << "C ";
}
};
int main()
{
C();
return 0;
}
Output:
A B C
Because class C constructor is specified as C():B(),A() (according to the class C constructor initializer list), the order of the base class constructors should be B before A. However, the base class constructor is only called in the order of inheritance in code output. Can somebody explain this behavior to me?