You will spend more of week two reading error messages than writing code. Here are the seven you will actually meet, with the real output — including three that never complain at all.
Compiler errors look like the machine shouting. They are actually a fixed format, saying which character it got to before it stopped understanding — and there are about eight of them you will meet over and over.
This level exists because the first month of C++ is mostly this, and nobody teaches it. You will spend more time reading these messages than writing code, and they go from terrifying to routine faster than you would think — but only once you know what you are looking at.
Fix only the first error, then compile again. One missing brace can produce forty messages, and thirty-nine of them are the compiler thrashing around after it lost its place. Beginners read all forty and despair. Read the first one. Fix it. Compile.
Every message below is real — produced by running the broken code through the same compiler you set up in level 1. Click through them now, calmly, so that when one appears at midnight you have already seen it.
Seven of these. Note that the last three are not errors at all — which is what makes them worse.
Notice what happened in the last three. An error stops the compile. A warning does not — your program is built, it runs, and it does the wrong thing while looking completely healthy.
That is the third column from level 11 — the kind of wrong that finishes cleanly and lies to you. And it is exactly why -Wall belongs in every compile you ever run: without it, some of these say nothing at all.
Integer division has no error and no warning, in any compiler, ever. 7 / 2 is 3, because both sides are whole numbers so C++ does whole-number division and throws the remainder away. Your average comes out wrong, everything compiles, nothing complains. This will get you at least once this semester — and now you know its name.
Break the hello world program in a new way. Compile. Copy the exact message.
Write the plain-English translation next to it and what fixed it. One line each. No jargon allowed.
By week four you will have fifteen of them and you will stop needing the notebook — which is the point. The people who find this course hard are usually not worse at logic. They are just still frightened of the error messages, which makes them change things at random instead of reading. Reading is the whole skill.
Then compile again. Later messages are usually noise from the first mistake.
A missing semicolon is reported on the line after it. Always check the line above.
An error stops you. A warning lets a broken program run. Never compile without -Wall.
Not recall — these are the shapes an exam actually uses. Every answer below was produced by compiling and running the code, so if you disagree with one, the compiler is the one to believe.
Have a real go before revealing. Being wrong here is worth more than being right in three weeks.
The compiler says expected ‘;’ and points at line 5. Where is the missing semicolon most likely to be?
One mistake produces forty error messages. What should you do?
Which of these is the DANGEROUS kind of wrong?
← back to the whole C++ track · stuck on anything? ask peter.