#include <iostream>
#include<string>
bool findG( const std::string name)
{
return name.length() >= 3 && name[0] == 'H';
}
bool NotfindG( const std::string name)
{
return !findG(name);
}
int main()
{
std::string name = "agHello";
if(findG(name))
{
std::cout << "It found Hello\n";
}
else
{
std::cout << "It did not find hello \n";
}
}
如果找到参数中给出的字符串,您会看到一个返回的布尔函数。
我了解该功能在做什么。我的兴趣是知道NotfindG上面代码中函数的活动是什么?
bool NotfindG( const std::string name)
{
return !findG(name);
}
我看到有人在使用它,但对我来说,即使没有布尔函数NotfindG(我的意思是在 else 条件下),该函数也应该可以工作。你能给我一些关于为什么有人会使用它的理由吗?