错误提示: ../main.cpp:35: error: passing 'const StudentT' as 'this' argument of 'int StudentT::getId()' discards qualifiers ../main.cpp:35: error: passing 'const StudentT' as 'this' argument of 'std::string StudentT::getName()' discards qualifiers 原因: std::set的对象存储const S...
错误提示: ../main.cpp:35: error: passing 'const StudentT' as 'this' argument of 'int StudentT::getId()' discards qualifiers ../main.cpp:35: error: passing 'const StudentT' as 'this' argument of 'std::string StudentT::getName()' discards qualifiers 原因: std::set的对象存储const S...
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,...
20. 我一开始在成员函数 fetchWeather(const QString &cityName) 后面加上了 const 关键字,而函数后面加上 const 关键字代表在该函数中不能修改成员变量,而该函数中就是需要对成员变量进行操作,所以违反了该规定,只要将 const 关键字去掉...
Attempting to compile this gives: error: passing 'const MyData' as 'this' argument of 'bool MyData::operator<(MyData)' discards qualifiers c++ class sorting vector Share Improve this question Follow edited Oct 23, 2011 at 22:32 asked Oct 23, 2011 at 22:12 Matt ...
error: passing ‘const Objectmap {aka const std::map<std::basic_string<char>, std::shared_ptr<Objects> >}’ as ‘this’ argument of ‘std::map<_Key, _Tp, _Compare, _Alloc>::iterator std::map<_Key, _Tp, _Compare, _Alloc>::erase(std::map<_Key, _Tp, _Compare, _Alloc>::co...
void process(const VideoFrame* pFrame) { pFrame->saveToJpeg(); } 编译时出错: error: passing ‘const VideoFrame’ as ‘this’ argument discards qualifiers [-fpermissive] 1. 2. 3. 4. 5. 6. 7. 原因是参数作为const。修改如下即可: ...
在getX()和getY()函数定义后加上const,即int getX() const,int getY() cosnt。
passing as 'this' argument discards qualifiers [-fpermissive] 上网查资料后发现是因为const函数里有调用非const的函数,所以会报这个错。[1] 解决方法有 solu:不要把函数设成const === [1]https://blog.csdn.net/Pabebe/article/details/83217119
bigNum.cpp:102:6: note: passing ‘const BigNum*’ as ‘this’ argument discards qualifiers 错误点在于 n 是用 const 修饰的,他只能调用 const 函数。尽管那个函数并不会修改 n 的值。 因此需要修改成: bool BigNum::operator==(constint&n)const{...} ...