class GenericClass{};
struct TestStruct
{
int iValue;
TestStruct(int i) :iValue(i) {}
int f(int j)
{
cout << "f(): " << iValue + j << endl;
return iValue + j;
}
};
int main()
{
TestStruct ts(99);
typedef int (GenericClass::* genericMemFuncType)(int);
GenericClass* p = reinterpret_cast<GenericClass*>(&ts);
genericMemFuncType pFunc = reinterpret_cast<genericMemFuncType>(&TestStruct::f);
int result = (p->*pFunc)(1);
cout << result << endl;
}
문법상 말이 안되는데 이걸 컴파일해주네 ㅋㅋ
- dc official App
reinterpret cast가 존나 강력하긴하지. 양날검임
저래놓고 TsetStruct::f 가 불림ㅋㅋ 멤버변수도 그대로 읽어오면서 - dc App
맴버펑션 이벤트 콜백시스템 한번해보셈
ㅇㅇ 일단 이거가지고 C# delegate 비슷하게 만들긴 했음 - dc App
얼ㅋ C++ 델리게이트 언리얼에도 있는데 문서화도 되어잇고 소스도 오픈소스니까 그것도 공부해봐. 전처리기떡칠이긴한데 영감얻는데 좋음 ㅇㅅㅇ