Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- class command_message_1
- {
- public:
- };
- class command_message_2
- {
- public:
- };
- class other_message_1
- {
- public:
- };
- template<class Message>
- void handle_cmd(const Message& message)
- {
- std::cout << "handle command message" << std::endl;
- }
- template<class SuperClass>
- class Layer : public SuperClass
- {
- public:
- template<class Message>
- void test(const Message& message)
- {
- SuperClass::test(message);
- }
- void test(const command_message_1& message)
- {
- handle_cmd(message);
- }
- void test(const command_message_2& message)
- {
- handle_cmd(message);
- }
- };
- class final
- {
- public:
- void test(const other_message_1& message)
- {
- std::cout << "handle message" << std::endl;
- }
- };
- int main(int argc, char const *argv[])
- {
- command_message_1 cmd1;
- command_message_2 cmd2;
- other_message_1 other;
- Layer<final> stack;
- stack.test(cmd1);
- stack.test(cmd2);
- stack.test(other);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement