Created
April 12, 2021 15:58
-
-
Save gonsolo/eb9410346f579cff0606880eaa4acb9c to your computer and use it in GitHub Desktop.
Mixin in c++
This file contains 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 <iostream> | |
using namespace std; | |
class A { | |
public: | |
void a() { cout << "a" << endl; } | |
}; | |
template<typename T> struct Mixin: T { | |
public: | |
void twice() { | |
this->a(); | |
this->a(); | |
} | |
}; | |
void mixin() { | |
Mixin<A> ma; | |
ma.twice(); | |
} | |
int main() { | |
mixin(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment