class X
{
protected:
void protectedFunction() { cout << "I am protected" ; }
};
class Y : public X
{
public:
using X::protectedFunction;
};
int main()
{
Y y1;
y1.protectedFunction();
}
This way I am able to expose one of the functions of the base class.
Yes it does and that's why protected has received a fair share of criticism.
Bjarne Stroustrup, the creator of C++, regrets this in his excellent book The Design and Evolution of C++:
One of my concerns about protected is exactly that it makes it too easy to use a common base the way one might sloppily have used global data....In retrospect, I think that protected is a case where "good arguments" and fashion overcame my better judgement and my rules of thumb for accepting new features.