O'Reilly logo

Sams Teach Yourself C++ in 24 Hours, Third Edition by Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Compile Errors

Compile-time errors can occur for any number of reasons. Usually they are a result of a typo or other inadvertent minor error. Some compilers will not only tell you what you did wrong, they'll point you to the exact place in your code where you made the mistake. And some will even suggest a remedy!

You can see how your compiler will react by intentionally putting an error into your program. If HELLO.CPP ran smoothly, edit it now and remove the closing brace on line 6. Your program will now look like Listing 1.2.

Listing 1.2. Demonstration of Compiler Error
0:  #include <iostream>
1:
2:  int main()
3:  {
4:      std::cout << "Hello World!\n";
5:      return 0;

Recompile your program and you will see an error that looks similar to

 Line Unit ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required