Monday, June 28, 2004

VJs Tip Of The Day - June 28th 2004

Virtual/Abstract members of a class

Virtual or Abstract members of a class cannot be private... Well just think, if you make them private why would you make them virtual or abstract anyways...:-)


PS: This tip is suffering from "Case of Monday" syndrome... :-)

2 comments:

Anonymous said...

This seems incorrect. as a matter of fact, good designers try to make virtual functions private. They cannot be called from the derived class, but they can be overridden.

Tim said...

The non-virtual interface (NVI) idiom says that there shouldn't be any virtual methods in a class' public interface. I don't strictly follow this idiom but there are times when adhering to it really pays off.

See also: http://www.gotw.ca/publications/mill18.htm