As I understand it, when I initialise the base class in the derived class initialiser list, the base class is immediately constructed and base class elements should then be available. If this is right, why doesn't this work?
class Base
{
public:
int elem;
}
class Derived : public Base
{
Derived() : Base(), elem(1) {}
// error: class 'Derived' does not have any field named 'elem'
}
NOTE: In my case I cannot make any changes to Base (it is a fixed interface class).
Base's job to initialize that, IMO.Baseis an interface containing call-back function objects that an implementation (Derived) can define.