You might see some C++ programs that runs without the standard namespace library. The using namespace std
line can be omitted and replaced with the std
keyword, followed by the ::
operator for string
(and cout
) objects:
#include <iostream>
#include <string>
int main() {
std::string greeting = "Hello";
std::cout << greeting;
return 0;
}
Try it Yourself »
It is up to you if you want to include the standard namespace library or not.
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!