How can I create mixin classes that share same members? I know this is probably a bad design choice but it is my last resort.
here is an example of what I mean. though they are not sharing the same pointer.
struct Full{
int a = 213;
int b = 500;
int c = 400;
};
struct ProxyA{
std::shared_ptr<Full> full;
void say_a(){
std::cout << full->a;
}
};
struct ProxyB{
std::shared_ptr<Full> full;
void say_b(){
std::cout << full->b;
}
};
struct FullProxy: public ProxyA, public ProxyB{
std::shared_ptr<Full> full;
FullProxy(std::shared_ptr<Full> full_):
full{full_}{};
void say_c(){
std::cout << full->c << "\n";
}
};
int main() {
FullProxy foo(std::make_shared<Full>());
foo.say_a();
foo.say_b();
foo.say_c();
}
output:
ASM generation compiler returned: 0
Execution build compiler returned: 0
Program returned: 139
Program terminated with signal: SIGSEGV
Note that I can't use templates because these
classes should have I realized that Qt does not support multiple inheritance so it won't work for Qt.Q_PROPERTY
s and Qt doesn't support templates.