Код: Выделить всё
struct SlotA
{
virtual void func(int value) = 0;
};
struct SlotB
{
virtual void func(int value) = 0;
};
class MultiObserver :
public SlotA,
public SlotB
{
public:
void SlotA::func(int value) override
{
aValue = value;
}
void SlotB::func(int value) override
{
aValue = value;
}
int aValue = 0;
int bValue = 0;
};
void main()
{
MultiObserver mo;
SlotA* a = &mo;
a->func(1);
SlotB* b = &mo;
b->func(2);
}
Код: Выделить всё
error: cannot define member function ‘{anonymous}::SlotA::func’ within ‘{anonymous}::MultiObserver’
error: cannot define member function ‘{anonymous}::SlotB::func’ within ‘{anonymous}::MultiObserver’
Подробнее здесь: https://stackoverflow.com/questions/798 ... se-classes
Мобильная версия