1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class Test{
public:
template<typename ObjectType, typename ReturnType,typename ParameterType>
void doit(size_t id, ReturnType (ObjectType::*memberFunctionPointer)( const ParameterType& ), const ParameterType& parameter)
{
if(id >= m_objects.size())
return;

return (m_objects[id]->*memberFunctionPointer)(parameter);
}
private:
Test2 m_objects;
}

懶得container 去Call Test2 的Function 又做判斷..寫了一個這樣的template
不過使用上好醜= =
Test test;
test.doit(0, &Test2::haha, die());
有人有比較聰明的寫法嗎..orz