|
|
|
|
3: The C in C++
Since C++ is based on C, you must
be familiar with the syntax of C in order to program in C++, just as you
must be reasonably fluent in algebra in
order to tackle calculus.
If you’ve never seen
C before, this chapter will give
you a decent background in the style of C used in C++. If you are familiar with
the style of C described in the first edition of Kernighan & Ritchie (often
called K&R C), you will find some new and different
features in C++ as well as in Standard C. If you are familiar with Standard C,
you should skim through this chapter looking for features that are particular to
C++. Note that there are some fundamental C++ features introduced here, which
are basic ideas that are akin to the features in C or often modifications to the
way that C does things. The more sophisticated C++ features will not be
introduced until later chapters.
This chapter is a fairly fast coverage of
C constructs and introduction to some basic C++ constructs, with the
understanding that you’ve had some experience programming in another
language. A more gentle introduction to C is found in the
CD ROM packaged in the back of this book, titled
Thinking in C: Foundations for Java & C++ by Chuck Allison (published
by MindView, Inc., and also available at www.MindView.net). This is a seminar on
a CD ROM with the goal of taking you carefully through the fundamentals of the C
language. It focuses on the knowledge necessary for you to be able to move on to
the C++ or Java languages rather than trying to make you an expert in all the
dark corners of C (one of the reasons for using a higher-level language like C++
or Java is precisely so we can avoid many of these dark corners). It also
contains exercises and guided solutions. Keep in mind that because this chapter
goes beyond the Thinking in C CD, the CD is not a replacement for this
chapter, but should be used instead as a preparation for this chapter and for
the
book.
|
|
|