Beginner here, my simplified code:
A.h
class A{
public:
A(int x);
private:
int _x;
}
A.cpp
A::A(int x)
: _x(x)
{
}
B.h
class B : public A{
public:
B()
private:
int _y = 1;
}
B.cpp
B::B()
: A(1) //works
: A(_y) //doesn't work
{
}
Why does the initialization with a member of B not work, but with a bare integer it does. I mean I can just go for the working method but I'd like to know the cause.
Thanks for any helpers!:)