- c++编译代码遇到which is of non-class type
- 代码展示
- 分析
- 修改
粗心导致的一个问题,看了很久,记录一下
代码展示CmdType* Context::getCmdType(const string& req)
{
vector::iterator iter = _vecCmd.begin();
while((iter != _vecCmd.end()) && (iter->isSupportCmd(req)))
{
iter++;
return *iter;
}
return NULL;
}
In member function 'CmdType* Context::getCmdType(const std::string&) request for member 'isSupportCmd' in '* iter.__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator-> [with _Iterator = CmdType**, _Container = std::vector分析>]()', **which is of non-class type** 'CmdType*'
查看报错发现粗心导致类型错误, isSupportCmd的调用需要CmdType*,仔细查看代码发现iter->isSupportCmd(req) iter是cmdType**类型,*iter才是
修改iter->isSupportCmd(req) 修改(*iter)->isSupportCmd(req) 问题解决



