#include "delegate.hpp"
class Test
{
Delegate<Test> dmethod;
public:
Test()
{
dmethod.Set(&Test::method, this);
}
void method(void* data)
{
}
};
int main()
{
Test testing;
return 0;
}
Errors
delegate.hpp: In instantiation of ‘void Delegate<T>::Call(void*) [with T = Test]’:
delegateTest.cpp:25:1: required from here
delegate.hpp:30:9: error: must use ‘.*’ or ‘->*’ to call pointer-to-member function in ‘((Delegate<Test>*)this)->Delegate<Test>::func (...)’, e.g. ‘(... ->* ((Delegate<Test>*)this)->Delegate<Test>::func) (...)’
line 30 of delegate.hpp: (This ->* func)(indata);//If you don't know you cannot have space between -> and *, because you should use operator ->* here.
It will give you
undefined reference to `vtable for Callback'|
. To get rid of that you should define your Callback::Call() function ( or do virtualvoid Call(void* indata) = 0;)