Why is protected constructor raising an error this this code?
问题 One question about protected constructor. I learnt that the protected constructor can be used in the derived class. How ever, I found the code below has an error. Why does it happen like this? class A { protected: A(){} }; class B: public A { public: B() { A* f=new A(); // Why it is not working here } }; 回答1: This has nothing to do with constructors specifically. This is just how protected access works. The way protected access specifier works, it allows the derived class B to access the