Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Overriding virtual functions is a huge hole in information hiding.

In C++, the "Non-Virtual Interface" (NVI) design pattern recommends that interface classes declare nonvirtual public functions that delegate to private pure virtual functions to be implemented by derived classes. A base class destructor should be either public and virtual, or protected and nonvirtual. NVI allows the base class to add pre- and post-condition assertions to test the derived implementation classes. NVI should also alleviate the "fragile base class" problem with C++ binary compatibility.

https://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Non-Virtua...



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: