Why Comments Matter
A free lesson from Swipe Coding · C++, level 2 · updated October 2026
By the Swipe team, founded by Colin · how we make lessons
A comment is a note in the code that the C++ compiler completely ignores. Comments never change what a program does — they exist purely for humans who read the code: yourself a few weeks from now, or teammates who look at your code later.
#include <iostream>
int main() {
// This line greets the user
std::cout << "Hello, World!" << std::endl;
return 0;
}Comments are compiled and executed by the C++ compiler like normal code.
Code you write today, you often don't read again until weeks or months later — and by then you've forgotten why you wrote certain lines the way you did. A good comment immediately explains what's going on, without you having to think through the entire code again.
// TODO: Add an evening greeting later std::cout << "Good morning!" << std::endl;
A comment that marks an open task for later often begins with the word ____.
Comments are especially valuable when they explain WHY something is done in the code — not just WHAT is done. The "what" can often be read directly from the code. The "why", on the other hand, exists only in the mind of the person who wrote it.
// We print the banner twice so the automated test can detect it reliably std::cout << "Start\n"; std::cout << "Start\n";
What are comments in C++ mainly intended for?
Keep your streak going in Swipe Coding
Swipe through every level of C++ on your iPhone — with XP, stars, streaks, a personal advisor and the full track beyond these free levels.
Get the Swipe apps →