Last time we wrote C application, this time let’s do a C++.
Our Hello, World could look like this:
#include <iostream>
int main()
{
[]{ std::cout << "Hello, World from C++" << std::endl; }();
return 0;
}
Save it as hello-world-cpp.cpp and to compile it execute:
g++ -g -Wall -sdt=c++14 hello-world-cpp.cpp -o hello-world-cpp
Again you should see no output. To run it execute:
./hello-world-cpp
you should get "Hello, World from C++".
The only difference is we used different compiler alias: g++ instead of gcc and different -std parameter: c++14 instead of c99.