Protected member functions can only be called inside the base class or in its derived class. You cannot call them outside your class. Outside calling means calling a member function of a class-typed variable.
So
virtual f1(B*b) { return f2(b); }
is ok, because f2 operates on the class itself. (called inside)
But
virtual f2(B*b) { return b->f2(this); }
won't compile, because f2 operates on b not the class D itself. (called outside) It's illegal.
To fix it B::f2 should be public.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…