In member function'int Something::getValue2(const string&) const':17:68: error: passing'const std::unordered_map<std::basic_string<char>, int>'as'this'argument of'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type& std::unordered_map<_Key, _Tp,...
而函数后面加上 const 关键字代表在该函数中不能修改成员变量,而该函数中就是需要对成员变量进行操作,所以违反了该规定,只要将 const 关键字去掉即可!
error: passing 'const …' as 'this' argument of '…' discards qualifiers 3 error: passing 'const …' as 'this' argument of '…' discards qualifiers in calling method Load 7 more related questions Know someone who can answer? Share a link to this question via email, Twitter, or Fac...
../main.cpp:35: error: passing 'const StudentT' as 'this' argument of 'std::string StudentT::getName()' discards qualifiers 原因: std::set的对象存储const StudentT 。 所以当您尝试调用getId() const对象的编译器检测到一个问题,即你调用一个const对象的非const成员函数这是不允许的,因为非const...
../main.cpp:35: error: passing 'const StudentT' as 'this' argument of 'std::string StudentT::getName()' discards qualifiers 原因: std::set的对象存储const StudentT 。 所以当您尝试调用getId() const对象的编译器检测到一个问题,即你调用一个const对象的非const成员函数这是不允许的,因为非const...
passing as 'this' argument discards qualifiers [-fpermissive] 上网查资料后发现是因为const函数里有调用非const的函数,所以会报这个错。[1] 解决方法有 solu:不要把函数设成const === [1]https://blog.csdn.net/Pabebe/article/details/83217119
pFrame->saveToJpeg(); } 编译时出错: error: passing ‘const VideoFrame’ as ‘this’ argument discards qualifiers [-fpermissive] 1. 2. 3. 4. 5. 6. 7. 原因是参数作为const。修改如下即可: ((VideoFrame*)pFrame)->saveToJpeg(); 1....
在getX()和getY()函数定义后加上const,即int getX() const,int getY() cosnt。
bigNum.cpp:102:6: note: passing ‘const BigNum*’ as ‘this’ argument discards qualifiers 错误点在于 n 是用 const 修饰的,他只能调用 const 函数。尽管那个函数并不会修改 n 的值。 因此需要修改成: bool BigNum::operator==(constint&n)const{...} ...
error: passing 'const Foam::Vector<double>' as 'this' Argument discards qualifiers [-fpermissive] tangentialVelocity()[i] = tangentialVelocity_pos()[i]; As far as my search has brought me, it has something to do with the Vector fields being defined as constants, ...