C++C++ · Lesson 1 of 9
Hello, World!
C++ Hello World has a critical upgrade over C's version: it uses cout instead of printf, and the difference reveals everything about the two languages.
cout is the standard output stream. << is the stream insertion operator — it "inserts" data into the stream. endl flushes the buffer and adds a newline (use "\n" instead for performance in tight loops). std:: is the standard library namespace.
◆ Note
using namespace std; saves typing but pollutes the global namespace. In small programs and student code it's fine. In larger codebases, be explicit: std::cout, std::string, etc.
using namespace std; saves typing but pollutes the global namespace. In small programs and student code it's fine. In larger codebases, be explicit: std::cout, std::string, etc.