C++ 为什么赢了';t std::string.find()用于<&引用;?

C++ 为什么赢了';t std::string.find()用于<&引用;?,c++,string,macos,C++,String,Macos,我有: #include <iostream> #include <string> int main(int argc, const char * argv[]) { std::string foo = "<!"; if (foo.find("<")) { std::cout<<"Found"; } return 0; } #包括 #包括 int main(int argc,const ch

我有:

#include <iostream>
#include <string>

int main(int argc, const char * argv[])
{

    std::string foo = "<!";

    if (foo.find("<")) {
        std::cout<<"Found";
    }

    return 0;
}
#包括
#包括
int main(int argc,const char*argv[]
{
std::string foo=“如果成功,它会找到”,返回找到其参数的索引,而不是布尔值


由于
“您的
if
语句未检查您是否正确找到子字符串,请尝试以下操作:

if (foo.find("<") != std::string::npos)

<代码>(fo)。(发现)它不是我所想到的。我是C++新手。
if (foo.find("<") != std::string::npos)