Skip to main content

Learning C++

Here are some places to get started learning C++!

Hello World!

The Code

helloworld.cpp
#include <iostream>

int main() {
std::cout << "Hello World!" << std::endl;

return 0;
}

OK! Now How Do I Run It?

Here there are a few options. You can always just use an online IDE like OnlineGDB. Compiling on your local machine, however, is a little more complicated than something like Python. Read here to learn more about the difference between compiled and interpreted languages. To install a compiler, follow this part of the VS Code C++ development guide.

Here is the important compilation command:

g++ helloworld.cpp -o helloworld

g++ is how we call the compiler, followed by the source file, followed by the -o flag which specifies the executable name. Executables are made of gibberish data that is not human readable, but basically contains a list of commands in sequence for the computer processor to run. In macOS and Linux executables generally have no extension, but in Windows they generally have a .exe extension.

Getting Started

Reference