包含类的功能的向量

时间:2015-08-13 13:38:59

标签: c++ vector

我目前正在尝试创建一个包含类函数的向量。

以下是我的代码:

{{1}}

函数“get ...”(非静态)返回值存储在共享资源上并已初始化。 但是,他们只返回值“1”。

一个想法?

1 个答案:

答案 0 :(得分:5)

当你取消引用$_GET并输出它时,你只是打印出一个函数指针的表示,它被隐式转换为<h4>Angular-xeditable Editable table (Bootstrap 3)</h4> <div ng-app="app" ng-controller="Ctrl"> <form editable-form name="tableform" onaftersave="saveTable()" oncancel="cancel()" shown="true"> <!-- table --> <table class="table table-bordered table-hover table-condensed"> <tr style="font-weight: bold"> <td style="width:40%">Name</td> <td style="width:30%">Status</td> <td style="width:30%">Group</td> <td style="width:30%"><span ng-show="tableform.$visible">Action</span></td> </tr> <tr ng-repeat="user in users | filter:filterUser"> <td> <!-- editable username (text with validation) --> <span editable-text="user.name" e-form="tableform" onbeforesave="checkName($data, user.id)"> {{ user.name || 'empty' }} </span> </td> <td> <!-- editable status (select-local) --> <span editable-select="user.status" e-form="tableform" e-ng-options="s.value as s.text for s in statuses"> {{ showStatus(user) }} </span> </td> <td> <!-- editable group (select-remote) --> <span editable-select="user.group" e-form="tableform" onshow="loadGroups()" e-ng-options="g.id as g.text for g in groups"> {{ showGroup(user) }} </span> </td> <td><button type="button" ng-show="tableform.$visible" ng-click="deleteUser(user.id)" class="btn btn-danger pull-right">Del</button></td> </tr> </table> <!-- buttons --> <div class="btn-edit"> <button type="button" class="btn btn-default" ng-show="!tableform.$visible" ng-click="tableform.$show()"> edit </button> </div> <div class="btn-form" ng-show="tableform.$visible"> <button type="button" ng-disabled="tableform.$waiting" ng-click="addUser()" class="btn btn-default pull-right">add row</button> <button type="submit" ng-disabled="tableform.$waiting" class="btn btn-primary">save</button> <button type="button" ng-disabled="tableform.$waiting" ng-click="tableform.$cancel()" class="btn btn-default">cancel</button> </div> </form> </div> 并输出为it,因为它不是空。

如果要调用该函数并输出返回值,则需要在实例上调用它:

bool

如果您使用的是C ++ 11,1可能更适合:

DataReader reader;

for(it = vec.begin(); it<vec.end(); it++)
    //dereference it to get member function pointer and call it on reader
    std::cout << (reader.*(*it))() << std::endl;