C++ virtual function is a useful tool for a superclass to control in what timing the subclass's virtual method override is called.
However, the virtual function mechanism calls only one of the overrides, which is the one overridden by the 'leaf' class in the class hierarchy.
When there are three or more classes in the hierarchy chain, and if some or all of the virtual method overrides need to be executed, the typical way we do is to call its direct superclass's virtual method manually in the subclass like this:

Child::foo() {
// ...
Parent::foo().
// ...
}
Sometimes the superclass's method needs to be called before the subclass does stuff for it and sometimes vice versa.
This manual chaining of methods is error prone and here is the solution for it.

Project Activity

See All Activity >

Follow MethodChainer

MethodChainer Web Site

Other Useful Business Software
MongoDB Atlas runs apps anywhere Icon
MongoDB Atlas runs apps anywhere

Deploy in 115+ regions with the modern database for every enterprise.

MongoDB Atlas gives you the freedom to build and run modern applications anywhere—across AWS, Azure, and Google Cloud. With global availability in over 115 regions, Atlas lets you deploy close to your users, meet compliance needs, and scale with confidence across any geography.
Start Free
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of MethodChainer!

Additional Project Details

Registered

2014-12-29