Problem scenario
You want to install a C++ compiler in Ubuntu. You want to write a basic C++ program and run it. How do you do these things?
Solution
1. As root, install a C++ compiler with this command:
apt install g++
2. Create a basic program. Here is an example. Name this file hello.cpp and put this as the content:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello from ContinualIntegration.com!" << endl;
return 0;
}
3. Compile the code with this command:
g++ hello.cpp
4. Run the byte code with this command:
./a.out