I wanted to make sure I still remembered all the ins and outs of inheritance, so I tried to break my compiler doing some wacky things with it.
I found that MSVC will not notice a protected constructor if you have the function body in the header. Put it in a .cpp, you're fine. MSVC sometimes doesn't notice you've made a change to implimentation in a header file, and requires you to clean and rebuild in order to have the change have any effect. This was not the case in this scenario.
I also found this weird break: if you declare a constructor or an assigment operator as protected, it won't let derived classes use them.
const BaseProtected & operator = (const BaseProtected & b);
const BaseProtected & BaseProtected::operator = (const BaseProtected & b)
prot = b.prot;
class DerivedProtected : public BaseProtected
I find that interesting. If you were to try and mess with the prot member after a and d are declared, it also issues errors saying you can't access protected memebers. As far as I know, this is not exptected behavior.
BaseProtected a, b; //MSVC error C2248
a = b;//MSVC error C2248
If anybody else would like to mess around with this in MSVC or any other compiler, please let me know what results you get.
If you'd like to enlighten me, I'm up for that, too.