|
|
|
|
|
|
|
LISTING 1.2 DEMONSTRATION OF COMPILER ERROR |
|
|
|
 |
|
|
|
|
1: #include <iostream.h>
2:
3: int main() ()
4: {
5: cout << Hello World!\n;
6: return 0; |
|
|
|
|
|
|
|
|
Recompile your program and you should see an error that looks similar to |
|
|
|
|
|
|
|
|
Hello.cpp, line 5: Compound statement missing terminating } in function main(). |
|
|
|
|
|
|
|
|
This error tells you the file and line number of the problem and what the problem is (although I admit it is somewhat cryptic). Note that the error message points you to line 5. The compiler wasn't sure if you intended to put the closing brace before or after the cout statement on line 5. Sometimes the errors just get you to the general vicinity of the problem. If a compiler could perfectly identify every problem, it would fix the code itself. |
|
|
|
|
|
|
|
|
After reading this chapter, you should have a good understanding of how C++ evolved and what problems it was designed to solve. You should feel confident that learning C++ is the right choice for anyone interested in programming in the next decade. C++ provides the tools of object-oriented programming and the performance of a systems level language, which makes C++ the development language of choice. |
|
|
|
|
|
|
|
|
In this very first chapter, you've learned how to write, compile, link, and run your first C++ program. You've learned what the normal development cycle is. You also learned a little of what object-oriented programming is all about. You will return to these topics during the remaining hours. |
|
|
|
|
|
|
|
|
Q What is the difference between a text editor and a word processor? |
|
|
|
|
|
|
|
|
A A text editor produces files with plain text in them. There are no formatting commands or other special symbols required by a particular word processor. Text files do not have automatic word wrap, bold print, italics, and so forth. Word processors usually can produce text files, but you must be careful to save your file as plain text. |
|
|
|
|
|