作者HenryLiKing (HenryLiKing)
看板C_and_CPP
标题[问题] 关於把function写进阵列里面
时间Thu Jun 2 22:06:33 2016
开发平台(Platform): (Ex: VC++, GCC, Linux, ...)
Visual studio 2013
额外使用到的函数库(Library Used): (Ex: OpenGL, ...)
问题(Question):
我想要把account 里面的函式放到一个阵列里面
但是我在Account外面的函式里面这样写
void(*functions[5])(string) = { newAC->setEmail, newAC->setPassword,
newAC->setName, newAC->setAddress, newAC->setPhone };
会出现底下的错误
error C2440: 'initializing' : cannot convert from
'overloaded-function' to 'void (__cdecl *)(std::string)'
我一直搞不懂到底错在哪里?
拜托各位替我解答了!
错误讯息:
喂入的资料(Input):
预期的正确结果(Expected Output):
错误结果(Wrong Output):
程式码(Code):(请善用置底文网页, 记得排版)
补充说明(Supplement):
如果有错误或是违规的地方告知後必定立马改善!
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 114.43.59.162
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/C_and_CPP/M.1464876396.A.2AB.html
※ 编辑: HenryLiKing (114.43.59.162), 06/02/2016 22:07:33
1F:→ EdisonX: 大写 'E' 修改标题 , 大写 'T' 修改内文 . 06/02 22:08
2F:→ EdisonX: 先把标题补上。 06/02 22:08
3F:→ wtchen: 请补上标题先 06/02 22:10
※ 编辑: HenryLiKing (114.43.59.162), 06/02/2016 22:11:48
抱歉 我已经改好了!
※ 编辑: HenryLiKing (114.43.59.162), 06/02/2016 22:12:26
4F:推 littleshan: member function pointer 不是 function pointer 06/02 22:53
5F:→ littleshan: 你的需求,要用std::function加上std::bind 06/02 22:54