Code

Open your favorite editor and create file helloworld.cpp.

#include <iostream>

int main() {
  std::cout << "Hello World!\n";
  return 0;
}

Compile

In order to compile it in a console run:

g++ helloworld.cpp -o helloworld

Then run it with:

./helloworld

Makefile

You can also create a makefile in the same directory as helloworld.cpp (https://www.gnu.org/software/make/manual/html_node/index.html).

helloworld:
	g++ helloworld.cpp -o helloworld

.PHONY: clean
clean:
	rm helloworld

Then, in order to compile it, just run

make