I'm trying to make one class which requires member variables to be initialized first. I know why this happens, but is there a way around this?
Current print order: second first
Wanted print order: first second
#include <iostream>
struct A {
A() {
std::cout << "first" << '\n';
}
};
struct B {
B() {
std::cout << "second" << '\n';
}
};
struct C : public B {
C() : a(), B() {
}
A a;
};
int main() {
C c;
return 0;
}