C++ a compiled language, which means a compiler needs to first translate your C++ source code into machine code before it can be run. There are two common ways for running C++ programs: using the command line or an IDE.
g++
and the filename to compile your program, then execute it with ./
and the name of the executable.g++ hello.cpp -o hello./hello
Style is what we call the conventions that govern our C++ code. These rules exist to keep the code base manageable and readable.
Here are some basic tips from Google’s C++ Style Guide:
#include
statements are mostly written at the beginning of any C/C++ program.#include <iostream>#include <string>using namespace std;// This program print out “Hello World!”int main() {string message = "Hello World!\n";cout << message;return 0;}