Inherited constructors make life easy.
Depending on your mood the (counter)intuitive scope behaviour of class members such that ordinary scope rules apply to class members. In particular, a member of a base class is not in the same scope as a member of a derived class.[1]
In C++03 this necessitated a lot of boiler plate code to lift up the base class constructors but in C++11 this lifting of base class constructors into the derived class scope is now easy-peasy with the using keyword. It makes for the effortless building of an exception class hierarchy:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "queue_exception.h" | |
namespace que { | |
struct queue_closed_exception: queue_exception { | |
using queue_exception::queue_exception; //ta-da! | |
}; | |
} |
References:
No comments:
Post a Comment