Can std::string be used without #include <string>? [duplicate]
问题 This question already has answers here : Why does omission of “#include <string>” only sometimes cause compilation failures? (6 answers) Closed 4 years ago . Here is my code: #include <iostream> int main(int argc, char const *argv[]) { std::string s = "hello"; std::cout << s.size() << std::endl; return 0; } To my surprise, I can compile and run it with clang++ , though I even don't add #include <string> . So, is it necessary to add #include <string> in order to use std::string ? 回答1: Your