int main(){
std::set<std::string> name_set;
name_set.insert("Tom");
name_set.insert("Bob");
name_set.insert("Jerry");
std::set<std::string>::iterator it = name_set.find("Tom");
if (it != name_set.end()){
std::cout << "Tom is in the Set." << std::endl;
} else {
std::cout << "Tom is not in the Set." << std::endl;
}
std::cout << "The size of name_set is " << name_set.size() << std::endl;
return 0;
}以上示例代码更换了一个数据类型,演示了对字符串类型的Set的操作,输出结果为: