Your First C++ Program
Every C++ program starts execution in a function called main. #include <iostream> pulls in the input/output library, and using namespace std lets you write cout instead of std::cout every time — a convenience this course uses throughout, though larger real-world codebases often prefer the explicit std:: prefix.
Compiling happens first
When you hit run, the compiler (g++) translates your entire file into a binary before executing a single line. If there's a type error or a syntax mistake anywhere, nothing runs at all — you get a compile error instead of output.
Comments
Comments work like in C and most C-family languages: anything after // on a line is ignored completely, existing purely so humans reading the code later understand why something is written the way it is.
Run it yourself
Here's a small program with a comment and two cout statements. This was actually executed to get the output shown below — try changing the text and running it yourself using the button under the example.
// This is a comment - C++ ignores it
#include <iostream>
using namespace std;
int main() {
cout << "Hello, World!" << endl;
cout << "Welcome to C++." << endl;
return 0;
}Hello, World! Welcome to C++.
Next: variables and types — the fundamental types, auto type inference, and const.
Practice exercise
Add a comment above your code, then print "Learning C++ one step at a time."