[Error] ‘npos’ was not declared in this scope
报错代码
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
int sum=0;
string temp=“67892”;
if(temp.find('2')!=npos)sum++;
cout<<sum;
return 0;
}
解决
if(temp.find('2')!=string::npos)sum++;
📍不过,已经使用了using namespace std;语句,为什么依然不能直接使用npos呢?

392

被折叠的 条评论
为什么被折叠?



