How can a private virtual method useful? The derived class can re-define the function but can't call? This technique is used to implement template method. The base class just need to provide a public wrapper that wraps the private virtual function, so the derived class can call the private virtual function (possibly overridden) indirectly.
It is known non-virtual interface (NVI) idiom . P170 effective c++
No comments:
Post a Comment