1.1 — C++ Basics & Program Structure

Let's start with the foundation. Every C++ program follows a basic structure that you need to understand cold before anything else makes sense.

The Basic Structure

#include <iostream>      // Preprocessor directive - includes input/output library
using namespace std;      // Lets us use 'cout' instead of 'std::cout'

int main() {               // Entry point - execution ALWAYS starts here
    cout << "Hello, World!" << endl;   // Statement 1
    return 0;               // Tells OS the program ended successfully
}

Breaking It Down Piece by Piece

1. Preprocessor Directives (#include)

2. Namespaces (using namespace std;)

3. The main() function

4. Statements & Semicolons