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
Build Securely on AWS with Proven Frameworks Icon
Build Securely on AWS with Proven Frameworks

Lay a foundation for success with Tested Reference Architectures developed by Fortinet’s experts. Learn more in this white paper.

Moving to the cloud brings new challenges. How can you manage a larger attack surface while ensuring great network performance? Turn to Fortinet’s Tested Reference Architectures, blueprints for designing and securing cloud environments built by cybersecurity experts. Learn more and explore use cases in this white paper.
Download 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