Is it ok to mark all pure virtual methods as private

May 15, 2014 at 11:55am
I have recently noticed that pure virtual methods marked private: in a base class seem to work fine in the derived class. I would have thought they needed to be marked protected:

My questions are is it ok to do this?
Are there any specific rules concerning this?
Is it bad or good programming practice?
May 15, 2014 at 12:00pm
It is fine for pure virtual methods to be marked private. It is also good practice, see here ( http://isocpp.org/wiki/faq/strange-inheritance#private-virtuals ) and here ( http://www.gotw.ca/publications/mill18.htm ) for more details.
Last edited on May 15, 2014 at 12:04pm
May 15, 2014 at 12:01pm
If you are not planning to call them from outside the class it's perfectly alright.
May 15, 2014 at 12:05pm
Thankyou both.

@Peter87 Wow it amazes me that you are always answering my questions +1Thanks.
Last edited on May 15, 2014 at 12:05pm
Topic archived. No new replies allowed.