⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 preface.htm

📁 This is the second part of that lab manual to teach you how to make real-time programme and how to d
💻 HTM
📖 第 1 页 / 共 3 页
字号:
and chairing the C++ and Java tracks at the Software Development Conference for
many years, that I and other speakers tended to give the typical audience too
many topics, too fast. So eventually, through both variety in the audience level
and the way that I presented the material, I would end up losing some portion of
the audience. Maybe it’s asking too much, but because I am one of those
people resistant to traditional lecturing (and for most people, I believe, such
resistance results from boredom), I wanted to try to keep everyone up to
speed.</FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">For a time, I was creating a number of
different presentations in fairly short order. Thus, I ended up learning by
experiment and iteration (a technique that also works well in C++ program
design). Eventually I developed a course using everything I had learned from my
teaching experience. It tackles the learning problem in discrete, easy-to-digest
steps and for a hands-on seminar (the ideal learning situation), there are
exercises following each of the presentations. </FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">The first edition of this book developed
over the course of two years, and the material in this book has been road-tested
in many forms in many different seminars. The feedback that I&#8217;ve gotten
from each seminar has helped me change and refocus the material until I feel it
works well as a teaching medium. But it isn&#8217;t just a seminar handout
&#8211; I tried to pack as much information as I could within these pages, and
structure it to draw you through, onto the next subject. More than anything, the
book is designed to serve the solitary reader, struggling with a new programming
language.</FONT><A NAME="_Toc312373771"></A><A NAME="_Toc462305068"></A><A NAME="_Toc519041868"></A><BR></P></DIV>
<A NAME="Heading7"></A><FONT FACE = "Verdana, Tahoma, Arial, Helvetica, Sans"><H2 ALIGN="LEFT">
Goals</H2></FONT>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">My goals in this book are
to:</FONT><BR></P></DIV>
<OL>
<LI><FONT FACE="Verdana">	</FONT><FONT FACE="Georgia">Present the material a
simple step at a time, so the reader can easily digest each concept before
moving on.</FONT><LI><FONT FACE="Verdana">	</FONT><FONT FACE="Georgia">Use
examples that are as simple and short as possible. This sometimes prevents me
from tackling &#8220;real-world&#8221; problems, but I&#8217;ve found that
beginners are usually happier when they can understand every detail of an
example rather than being impressed by the scope of the problem it solves. Also,
there&#8217;s a severe limit to the amount of code that can be absorbed in a
classroom situation. For this I sometimes receive criticism for using &#8220;toy
examples,&#8221; but I&#8217;m willing to accept that in favor of producing
something pedagogically
useful.</FONT><LI><FONT FACE="Verdana">	</FONT><FONT FACE="Georgia">Carefully
sequence the presentation of features so that you aren&#8217;t seeing something
you haven&#8217;t been exposed to. Of course, this isn&#8217;t always possible;
in those situations, a brief introductory description will be
given.</FONT><LI><FONT FACE="Verdana">	</FONT><FONT FACE="Georgia">Give you what
I think is important for you to understand about the language, rather than
everything I know. I believe there is an &#8220;information importance
hierarchy,&#8221; and there are some facts that 95% of programmers will never
need to know, but that would just confuse people and add to their perception of
the complexity of the language. To take an example from C, if you memorize the
operator precedence table (I never did) you can write clever code. But if
<I>you</I> have to think about it, it will confuse the reader/maintainer of that
code. So forget about precedence, and use parentheses when things aren&#8217;t
clear. This same attitude will be taken with some information in the C++
language, which I think is more important for compiler writers than for
programmers.</FONT><LI><FONT FACE="Verdana">	</FONT><FONT FACE="Georgia">Keep
each section focused enough so the lecture time &#8211; and the time between
exercise periods &#8211; is small. Not only does this keep the audience&#8217;
minds more active and involved during a hands-on seminar, but it gives the
reader a greater sense of
accomplishment.</FONT><LI><FONT FACE="Verdana">	</FONT><FONT FACE="Georgia">Provide
the reader with a solid foundation so they can understand the issues well enough
to move on to more difficult coursework and books (in particular, Volume 2 of
this
book).</FONT><LI><FONT FACE="Verdana">	</FONT><FONT FACE="Georgia">I&#8217;ve
endeavored not to use any particular vendor&#8217;s version of C++ because, for
learning the language, I don&#8217;t feel like the details of a particular
implementation are as important as the language itself. Most vendors&#8217;
documentation concerning their own implementation specifics is
adequate.</FONT><A NAME="_Toc312373772"></A><A NAME="_Toc462305069"></A><A NAME="_Toc519041869"></A></OL><A NAME="Heading8"></A><FONT FACE = "Verdana, Tahoma, Arial, Helvetica, Sans"><H2 ALIGN="LEFT">
Chapters<BR><A NAME="Index2"></A></H2></FONT>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">C++ is a language where new and different
features are built on top of an existing syntax. (Because of this it is referred
to as a <I>hybrid</I> object-oriented programming language.) As more people have
passed through the learning curve, we&#8217;ve begun to get a feel for the way
programmers move through the stages of the C++ language features. Because it
appears to be the natural progression of the procedurally-trained mind, I
decided to understand and follow this same path, and accelerate the process by
posing and answering the questions that came to me as I learned the language and
that came from audiences as I taught it.</FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">This course was designed with one thing
in mind: to streamline the process of learning the C++ language. Audience
feedback helped me understand which parts were difficult and needed extra
illumination. In the areas where I got ambitious and included too many features
all at once, I came to know &#8211; through the process of presenting the
material &#8211; that if you include a lot of new features, you have to explain
them all, and the student&#8217;s confusion is easily compounded. As a result,
I&#8217;ve taken a great deal of trouble to introduce the features as few at a
time as possible; ideally, only one major concept at a time per
chapter.</FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">The goal, then, is for each chapter to
teach a single concept, or a small group of associated concepts, in such a way
that no additional features are relied upon. That way you can digest each piece
in the context of your current knowledge before moving on. To accomplish this, I
leave some C features in place for longer than I would prefer. The benefit is
that you will not be confused by seeing all the C++ features used before they
are explained, so your introduction to the language will be gentle and will
mirror the way you will assimilate the features if left to your own
devices.</FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">Here is a brief description of the
chapters contained in this book:</FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia"><B> (5) Introduction to iostreams</B>.
One of the original C++ libraries &#8211; the one that provides the essential
I/O facility &#8211; is called iostreams. Iostreams is intended to replace
C&#8217;s <B>stdio.h </B>with an I/O library that is easier to use, more
flexible, and extensible &#8211; you can adapt it to work with your new classes.
This chapter teaches you the ins and outs of how to make the best use of the
existing iostream library for standard I/O, file I/O, and in-memory
formatting.</FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia"><B> (15) Multiple inheritance</B>. This
sounds simple at first: A new class is inherited from more than one existing
class. However, you can end up with ambiguities and multiple copies of
base-class objects. That problem is solved with virtual base classes, but the
bigger issue remains: When do you use it? Multiple inheritance is only essential
when you need to manipulate an object through more than one common base class.
This chapter explains the syntax for multiple inheritance, and shows alternative
approaches &#8211; in particular, how templates solve one common problem. The
use of multiple inheritance to repair a &#8220;damaged&#8221; class interface is
demonstrated as a genuinely valuable use of this feature.</FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia"><B>(16) Exception handling</B>. Error
handling has always been a problem in programming. Even if you dutifully return
error information or set a flag, the function caller may simply ignore it.
Exception handling is a primary feature in C++ that solves this problem by
allowing you to &#8220;throw&#8221; an object out of your function when a
critical error happens. You throw different types of objects for different
errors, and the function caller &#8220;catches&#8221; these objects in separate
error handling routines. If you throw an exception, it cannot be ignored, so you
can guarantee that <I>something</I> will happen in response to your
error.</FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia"><B>(17) Run-time type
identification</B>.<B> </B>Run-time type identification (RTTI) lets you find the
exact type of an object when you only have a pointer or reference to the base
type. Normally, you&#8217;ll want to intentionally ignore the exact type of an
object and let the virtual function mechanism implement the correct behavior for
that type. But occasionally it is very helpful to know the exact type of an
object for which you only have a base pointer; often this information allows you
to perform a special-case operation more efficiently. This chapter explains what
RTTI is for and how to use
it.</FONT><A NAME="_Toc312373773"></A><A NAME="_Toc462305070"></A><A NAME="_Toc519041870"></A><BR></P></DIV>
<A NAME="Heading9"></A><FONT FACE = "Verdana, Tahoma, Arial, Helvetica, Sans"><H2 ALIGN="LEFT">
Exercises</H2></FONT>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">I&#8217;ve discovered that simple
exercises are exceptionally useful during a seminar to complete a
student&#8217;s understanding, so you&#8217;ll find a set at the end of each
chapter.</FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">These are fairly simple, so they can be
finished in a reasonable amount of time in a classroom situation while the
instructor observes, making sure all the students are absorbing the material.
Some exercises are a bit more challenging to keep advanced students entertained.
They&#8217;re all designed to be solved in a short time and are only there to
test and polish your knowledge rather than present major challenges (presumably,
you&#8217;ll find those on your own &#8211; or more likely they&#8217;ll find
you).</FONT><A NAME="_Toc519041871"></A><BR></P></DIV>
<A NAME="Heading10"></A><FONT FACE = "Verdana, Tahoma, Arial, Helvetica, Sans"><H3 ALIGN="LEFT">
Exercise solutions</H3></FONT>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">Solutions to exercises can be found in
the electronic document <I>The C++ Annotated Solution Guide</I>, Volume 2 by
Chuck Allison, available for a small fee from
<A HREF="http://www.BruceEckel.com">www.BruceEckel.com</A>. [[ Note this is not
yet available
]]</FONT><A NAME="_Ref310733137"></A><A NAME="_Toc312373774"></A><A NAME="_Toc462305071"></A><A NAME="_Toc519041872"></A><BR></P></DIV>
<A NAME="Heading11"></A><FONT FACE = "Verdana, Tahoma, Arial, Helvetica, Sans"><H2 ALIGN="LEFT">
Source code</H2></FONT>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">The source code for this book is
copyrighted freeware, distributed via the web site http://www.BruceEckel.com.
The copyright prevents you from republishing the code in print media without
permission.</FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">Although the code is available in a
zipped file on the above web site, you can also unpack the code yourself by

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -