Sams Teach Yourself C++ in 21 Days

(singke) #1
Getting Started 21

1


LISTING1.2 Demonstration of Compiler Error


1: #include <iostream>
2:
3: int main()
4: {
5: std::cout << “Hello World!\n”;
6: return 0;

Recompile your program and you should see an error that looks similar to the following:
Hello.cpp(7) : fatal error C1004: unexpected end of file found
This error tells you the file and line number of the problem and what the problem is
(although I admit it is somewhat cryptic). In this case, the compiler is telling you that it
ran out of source lines and hit the end of the source file without finding the closing
brace.
Sometimes, the error messages just get you to the general vicinity of the problem. If a
compiler could perfectly identify every problem, it would fix the code itself.

Summary ................................................................................................................


After reading today’s lesson, 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. C++ provides the tools of
object-oriented programming and the performance of a systems-level language, which
makes C++ the development language of choice.
Today, you learned how to enter, compile, link, and run your first C++ program, and
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 next three weeks.

Q&A ......................................................................................................................


Q What is the difference between a text editor and a word processor?
A A text editor produces files with plain text in them. No formatting commands or
other special symbols are used that might be required by a particular word proces-
sor. Simple text editors do not have automatic word wrap, bold print, italic, and so
forth.
Free download pdf