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
Our Free Plans just got better! | Auth0 Icon
Our Free Plans just got better! | Auth0

With up to 25k MAUs and unlimited Okta connections, our Free Plan lets you focus on what you do best—building great apps.

You asked, we delivered! Auth0 is excited to expand our Free and Paid plans to include more options so you can focus on building, deploying, and scaling applications without having to worry about your security. Auth0 now, thank yourself later.
Try free now
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