Bring five readers who confirm their email and you get a month of the paper, free.

The paper is A$5 a month from day one. The Daily is free forever.

A program that says something

C++ · Lesson 1

A program that says something

Include, main, and std::cout.

Lessons · C++ · Lesson 1 of 10 · On the house

A program that says something

Include, main, and std::cout.

A newspaper still of a C++ lesson
Lesson 1 is on the house. The rest opens with the paper, the Daily, or a gift.

Here's the short version. C++ is C with more furniture. You still write a function called main. The operating system calls it. You return 0 if the night went well.

At the top, you include a header. iostream is the one that talks to the screen. std::cout is the stream. << feeds it. std::endl ends the line. Some people write '\n'. Both are fine at this desk.

The still

#include <iostream>

int main() {
    std::cout << "hello" << std::endl;
    return 0;
}
A whole program. The braces are the body of main.

You will not compile this in the browser. You match the source. On your machine, that's g++ hello.cpp -o hello, then ./hello. We'll get there in lesson 10.

Quiz

What is the name of the function the program starts in?

Check

Match the still: include iostream, int main, cout hello, return 0.

Semicolons end statements. Forget one and the compiler writes you a novel. Read the first error. Fix that. Then the next.

A program that says something · C++ — The Gold Standard