Skip to content

Instantly share code, notes, and snippets.

@gonsolo
Created April 12, 2021 15:58
Show Gist options
  • Save gonsolo/eb9410346f579cff0606880eaa4acb9c to your computer and use it in GitHub Desktop.
Save gonsolo/eb9410346f579cff0606880eaa4acb9c to your computer and use it in GitHub Desktop.
Mixin in c++
#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