积极答复者
在类内部如何使用函数指针进行操作

问题
-
在一个类内部能不能用函数指针进行操作??
如果能,该如何使用??如果不能,我这个问题应该如何解决?
那么我的问题来了:需要从配置文件中读取内容,然后执行此类的对应的函数。类名:CTransInfo,读配置文件内容
map CTransInfo::LoadConfigFile(char* filePath);执行函数几个: Open, Close, Reset等,参数列表相同,内部的实现是不同的。
从配置文件中,读回内容是string型的。
配置文件格式如下
[Config]
Hello=Open
Goodbye=Close
假如:读回key是Hello就要执行Open, Goodbye执行Close。有一段内容需要跟Config的key比较,然后再执行。较笨的方法是循环比较key然后再比较value是Open, 还是Close,或是其他
答案
-
你好,
在类内可以使用函数指针,你可以参考一下类内使用函数指针的例子然后按照你自己的需求实现。
http://www.codeproject.com/Articles/7150/Member-Function-Pointers-and-the-Fastest-Possible
http://blog.csdn.net/apengjiang/article/details/7088263
http://zhangzhibiao02005.blog.163.com/blog/static/37367820201091775154770/
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.- 已标记为答案 May Wang - MSFT 2014年11月27日 1:50
全部回复
-
你好,
在类内可以使用函数指针,你可以参考一下类内使用函数指针的例子然后按照你自己的需求实现。
http://www.codeproject.com/Articles/7150/Member-Function-Pointers-and-the-Fastest-Possible
http://blog.csdn.net/apengjiang/article/details/7088263
http://zhangzhibiao02005.blog.163.com/blog/static/37367820201091775154770/
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.- 已标记为答案 May Wang - MSFT 2014年11月27日 1:50