map管理成員函式指標

2021-07-15 04:20:05 字數 529 閱讀 8943

**:

概括:將成員函式指標名和同名的string型別的變數名進行繫結,插入到map中。

在使用時就可以通過找到string型別的變數名來使用同名的函式

#include "iostream"

#include "string"

#include "map"

using namespace std;

class

test

void call(string strfun)

protected :

typedef void (test::*mfun)();

mapm_mapfun;

};int main()

-----------------

結果:call test::fun1

call test::fun2

call test::fun3

no function

: test

::fun4

map與成員函式指標的使用

c 新加三種運算子支援成員函式指標 在使用成員函式指標時必須用物件去呼叫,否則編譯錯誤。1,成員函式指標的宣告與定義,如 class xx 2,成員函式指標的使用,如 auto ite m funprocmap.find command if ite m funprocmap.end 3,c 例子,...

管理指標成員

void test bhasptr class ahasptr int get ptr const int get int const void set ptr int p void set int int i int get ptr val const void set ptr val int v...

管理指標成員

include include plain ptr.h include value ptr.h include smart ptr.h using namespace std void test ahasptr void test chasptr void test bhasptr int main...