C++ HelloWorld 示例
代码:
// helloworld.cpp
#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector<string> msg = {
"hello", "world", "c++"};
for (auto it = msg.begin(); it != msg.end(); ++it)
{
cout << *it << (((it + 1) != msg.end()) ? " " : "\n") << flush;
}
return EXIT_SUCCESS;
}
编译命令:
$ gcc helloworld.cpp -o helloworld --std=c++11
输出:
hello world c++