Why is my base class constructor called this this instance?
#include <iostream>
using namespace std;
class A {
public:
A() {
cout << "A" << endl;
}
};
class B : public A {
public:
B() {
cout << "B" << endl;
}
};
int main() {
B b;
getchar();
return 0;
}
The output is
A
B
Why is A called before B is? And why is A even called in the first place?