且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

指向成员函数语法的指针

更新时间:2023-11-12 23:32:10

简单的语法细节.

func = &TestClass::TestMethod;
//     ^ Missing ampersand to form a pointer-to-member

TestClass tc;
(tc.*func)(10, 20);
// ^^ Using the dot-star operator to dereference the pointer-to-member,
// while minding its awkward precedence with respect to the call operator.