我有一个有签名的功能:
int alarmCreate(const std::string& familyCode, std::vector<std::pair<std::string,boost::any> >& alarmparameters, const std::string& description);
可以看出,它有三个参数;串,向量,字符串。
但是当我构建我的项目时,我收到一个错误:
/root/projects/test/test.cpp:152:对
的未定义引用 redisHandler::alarmCreate(std::string const&, std::vector<std::pair<std::string, boost::any>, std::allocator<std::pair<std::string, boost::any> > >&, std::string const&)
我看到第四个参数类型为std :: allocator,我无法理解它的来源。
你们有什么想法,为什么我的功能中有第四个参数?
编辑::事实证明有3个参数。但我仍然很好奇为什么我得到错误。此函数位于静态库中。当我用“nm”搜索这个库时,我看到我的func存在(可以在下面看到)。你知道我错过了什么吗?
[root @~ / projects / test / test] #nm ../../lib/libredis.a | grep alarmCreate
000000000000073c T_ZN12redisHandler11alarmCreateERKSsRSt6vectorISt4pairISsN5boost3anyEESaIS6_EES1 _
答案 0 :(得分:4)
这是vector
的模板参数。每个标准容器都有一个分配器,它有一个默认值,所以你不必为此烦恼。
您的方法可能已声明但未定义。