(eBook PDF) C++ How to Program 10th Edition by Paul J. Deitel pdf download
(eBook PDF) C++ How to Program 10th Edition by Paul J. Deitel pdf download
https://ebooksecure.com/product/ebook-pdf-c-how-to-program-10th-
edition-by-paul-j-deitel/
http://ebooksecure.com/product/ebook-pdf-visual-c-how-to-
program-6th-edition-by-paul-j-deitel/
https://ebooksecure.com/download/c-how-to-program-ebook-pdf/
http://ebooksecure.com/product/ebook-pdf-c-how-to-program-global-
edition-8th-by-paul-deitel/
https://ebooksecure.com/download/c-how-to-program-9th-global-
edition-ebook-pdf/
(eBook PDF) Java How to Program, Early Objects 11th
Edition by Paul J. Deitel
http://ebooksecure.com/product/ebook-pdf-java-how-to-program-
early-objects-11th-edition-by-paul-j-deitel/
https://ebooksecure.com/download/c-how-to-program-an-objects-
natural-approach-11e-ebook-pdf/
https://ebooksecure.com/download/c-how-to-program-with-case-
studies-in-applications-and-systems-programming-global-edition-
ebook-pdf/
http://ebooksecure.com/product/ebook-pdf-java-how-to-program-
early-objects-10th/
http://ebooksecure.com/product/c-how-to-program-early-objects-
version-9th-edition-ebook-pdf/
Trademarks
DEITEL and the double-thumbs-up bug are registered trademarks of Deitel and Associates, Inc.
Carnegie Mellon Software Engineering Institute™ is a trademark of Carnegie Mellon University.
CERT® is registered in the U.S. Patent and Trademark Office by Carnegie Mellon University.
UNIX is a registered trademark of The Open Group.
Microsoft and/or its respective suppliers make no representations about the suitability of the information
contained in the documents and related graphics published as part of the services for any purpose. All
such documents and related graphics are provided “as is” without warranty of any kind. Microsoft and/
or its respective suppliers hereby disclaim all warranties and conditions with regard to this information,
including all warranties and conditions of merchantability, whether express, implied or statutory, fitness
for a particular purpose, title and non-infringement. In no event shall Microsoft and/or its respective sup-
pliers be liable for any special, indirect or consequential damages or any damages whatsoever resulting
from loss of use, data or profits, whether in an action of contract, negligence or other tortious action,
arising out of or in connection with the use or performance of information available from the services.
The documents and related graphics contained herein could include technical inaccuracies or typograph-
ical errors. Changes are periodically added to the information herein. Microsoft and/or its respective sup-
pliers may make improvements and/or changes in the product(s) and/or the program(s) described herein
at any time. Partial screen shots may be viewed in full within the software version specified.
Microsoft® and Windows® are registered trademarks of the Microsoft Corporation in the U.S.A. and
other countries. Screen shots and icons reprinted with permission from the Microsoft Corporation. This
book is not sponsored or endorsed by or affiliated with the Microsoft Corporation.
Throughout this book, trademarks are used. Rather than put a trademark symbol in every occurrence of
a trademarked name, we state that we are using the names in an editorial fashion only and to the benefit
of the trademark owner, with no intention of infringement of the trademark.
Contents
Chapters 23–26 and Appendices F–J are PDF documents posted online at the book’s
Companion Website, which is accessible from
http://www.pearsonhighered.com/deitel
Preface xxiii
8 Pointers 339
8.1 Introduction 340
8.2 Pointer Variable Declarations and Initialization 341
8.2.1 Declaring Pointers 341
8.2.2 Initializing Pointers 342
8.2.3 Null Pointers Prior to C++11 342
xii Contents
9.2.7 Time Class Member Function setTime and Throwing Exceptions 392
9.2.8 Time Class Member Function toUniversalString and
String Stream Processing 392
9.2.9 Time Class Member Function toStandardString 393
9.2.10 Implicitly Inlining Member Functions 393
9.2.11 Member Functions vs. Global Functions 393
9.2.12 Using Class Time 394
9.2.13 Object Size 396
9.3 Compilation and Linking Process 396
9.4 Class Scope and Accessing Class Members 398
9.5 Access Functions and Utility Functions 399
9.6 Time Class Case Study: Constructors with Default Arguments 399
9.6.1 Constructors with Default Arguments 399
9.6.2 Overloaded Constructors and C++11 Delegating Constructors 404
9.7 Destructors 405
9.8 When Constructors and Destructors Are Called 405
9.8.1 Constructors and Destructors for Objects in Global Scope 406
9.8.2 Constructors and Destructors for Non-static Local Objects 406
9.8.3 Constructors and Destructors for static Local Objects 406
9.8.4 Demonstrating When Constructors and Destructors Are Called 406
9.9 Time Class Case Study: A Subtle Trap—Returning a Reference or a
Pointer to a private Data Member 409
9.10 Default Memberwise Assignment 411
9.11 const Objects and const Member Functions 413
9.12 Composition: Objects as Members of Classes 415
9.13 friend Functions and friend Classes 421
9.14 Using the this Pointer 423
9.14.1 Implicitly and Explicitly Using the this Pointer to Access an
Object’s Data Members 424
9.14.2 Using the this Pointer to Enable Cascaded Function Calls 425
9.15 static Class Members 429
9.15.1 Motivating Classwide Data 429
9.15.2 Scope and Initialization of static Data Members 429
9.15.3 Accessing static Data Members 430
9.15.4 Demonstrating static Data Members 430
9.16 Wrap-Up 433
E Preprocessor 981
E.1 Introduction 982
E.2 #include Preprocessing Directive 982
E.3 #define Preprocessing Directive: Symbolic Constants 983
E.4 #define Preprocessing Directive: Macros 983
E.5 Conditional Compilation 985
E.6 #error and #pragma Preprocessing Directives 987
E.7 Operators # and ## 987
E.8 Predefined Symbolic Constants 987
E.9 Assertions 988
E.10 Wrap-Up 988
Chapters 23–26 and Appendices F–J are PDF documents posted online at the book’s
Companion Website, which is accessible from
http://www.pearsonhighered.com/deitel
23 Other Topics
24 C++11 and C++14: Additional Features
25 ATM Case Study, Part 1: Object-Oriented
Design with the UM
26 ATM Case Study, Part 2: Implementing an
Object-Oriented Design
xxii Contents
and
http://www.pearsonhighered.com/deitel
Use the source code we provide to run each program as you study it.
1. Computer Science Curricula 2013 Curriculum Guidelines for Undergraduate Degree Programs in Com-
puter Science, December 20, 2013, The Joint Task Force on Computing Curricula, Association for
Computing Machinery (ACM), IEEE Computer Society.
Another Random Scribd Document
with Unrelated Content
3. Our Heritage.—A. Christianity.
We shall find that the one definite and unswerving tendency of the
traditional thought of Europe has been, first, to establish on earth
that equality between men which from the outset Christianity had
promised them in Heaven; secondly, to assail the prestige of man by
proving that other tenet of the Faith which maintains the general
depravity of human nature; and thirdly, to insist upon truth in the
Christian sense; that is, as an absolute thing which can be, and must
be, made common to all.
At the root of all our science, all our philosophy, and all our
literature, the three fundamental doctrines of Christianity: the
equality of all souls, the insuperable depravity of human nature, and
the insistence upon Truth, are the ruling influences.
By means of the first and third doctrines equality was established in
the spirit, and by means of the second it was established in the
flesh.[13]
By means of the first, each individual, great or small, was granted an
importance[14] undreamt of theretofore,[15] while the lowest were
raised to the highest power; by means of the second, in which the
pride of mankind received a snub at once severe and merciless, the
highest were reduced to the level of the low, while the low were by
implication materially raised; and by means of the third, no truth or
point of view which could not be made general could be considered
as a truth or a point of view at all. Practically it amounted to this,
that in one breath mankind was told, first,
Thy Lord for thee the Cross endured
To save thy soul from Death and Hell;"[16]
secondly, "Thou shalt have no other God before Me;" and thirdly,
"From Greenland's icy mountains
To India's coral strand,
... every prospect pleases,
And only man is vile."[17]
But in each case, as I have pointed out, it was the higher men who
suffered. Because they alone had something to lose. The first notion
—that of equality, threatened at once to make them doubt their own
privileges and powers, to throw suspicion into the hearts of their
followers, and to make all special, exceptional and isolated claims
utterly void. The third—the insistence upon a truth which could be
general and absolute, denied their right to establish their own truths
in the hearts of men, and to rise above the most general truth which
was reality; while in the second—the Semitic doctrine of general sin,
which held that man was not only an imperfect, but also a fallen
being, and that all his kind shared in this shame—there was not
alone the ring of an absence of rank, but also of a universal
depreciation of human nature which was ultimately to lead, by
gradual stages, from a disbelief in man himself to a disbelief in
nobles, in kings and finally in gods.[18]
At one stroke, not one or two human actions, but all human
performances, inspirations and happy thoughts, had been stripped of
their glory and condemned. Man could raise himself only by God's
grace —that is to say, by a miracle, otherwise he was but a fallen
angel, aimlessly beating the air with his broken wings.
These three blows levelled at the head of higher men were fatal to
the artist; for it is precisely in the value of human inspirations, in the
efficiency of human creativeness, and in the irresistible power of
human will, that he, above all, must and does believe. It is his
mission to demand obedience and to procure reverence; for, as we
shall see, every artist worthy the name is at heart a despot.[19]
Fortunately, the Holy Catholic Church intervened, and by its rigorous
discipline and its firm establishment upon a hierarchical principle,
suppressed for a while the overweening temper of the Christian soul,
and all claims of individual thought and judgment, while it also
recognized an order of rank among men; but the three doctrines
above described remained notwithstanding at the core of the
Christian Faith, and awaited only a favourable opportunity to burst
forth and blight all the good that the Church had done.
This favourable opportunity occurred in the person of Martin Luther.
The Reformation, in addition to reinstating, with all their evil
consequences, the three doctrines mentioned above, also produced
a certain contempt for lofty things and an importunate individualism
which has done nought but increase and spread from that day to
this.
Individualism, on a large scale, of course, had been both tolerated
and practised in Gothic architecture, and on this account the
buildings of the Middle Ages might be said to breathe a more truly
Christian spirit[20] than most of the sculpture and the painting of the
same period, which are more hieratic.[21] But it was not until the
Reformation began to spread that the most tiresome form of
individualism, which we shall call Amateurism,[22] received, as it
were, a Divine sanction; and there can be no doubt that it is against
this element in modern life that not only Art, but all forces which aim
at order, law and discipline, will eventually have to wage their most
determined and most implacable warfare.
B. Protestantism.
For Protestantism was nothing more nor less than a general rebellion
against authority.[23] By means of it the right of private judgment
was installed once more, and to the individual was restored that
importance which Christianity had acknowledged from the first, and
which only the attitude of the Church had been able to modify. The
layman, with his conscience acknowledged to be the supreme
tribunal, was declared a free man, emancipated even from the law,
[24] or, as Luther said, "free Lord of all, subject to none."[25]
[44] See Froude's The Earl of Beaconsfield (9th Edition), pp. 176,
177: "The discoveries of science are not, we are told, consistent
with the teachings of the Church.... It is of great importance
when this tattle about science is mentioned, that we should
attach to the phrase precise ideas. The function of science is the
interpretation of nature, and the interpretation of the highest
nature is the highest science. What is the highest nature? Man is
the highest nature. But I must say that when I compare the
interpretation of the highest nature by the most advanced, the
most fashionable school of modern science with some other
teaching with which we are familiar I am not prepared to admit
that the lecture room is more scientific than the Church. What is
the question now placed before society, with a glib assurance the
most astounding? The question is this: Is man an ape or an
angel? I, my Lord, I am on the side of the angels. I repudiate with
indignation and abhorrence the contrary view, which I believe
foreign to the conscience of humanity."
[45] See p. 37.**
[46] Spencer, Social Statics (Ed. 1892), p. 27.
[47] Ibid., p. 31.
[48] Two Christian principles are concealed here: 1. The depravity
of man. 2. Faith in a moral order of things.
[49] I have discussed this question, with as much detail as the
space would allow, in Nietzsche, his Life and Works, Chap. IV.
(Constable's Philosophies Ancient and Modern). See also my letter,
"Nietzsche and Science," in the Spectator of 8th January, 1910.
[50] G. M., p. 17.
[51] A History of Æsthetic, p. 445.
[52] A., Aph. 43.
[53] Culture and Anarchy (Smith, Elder, 1909), p. 10.
[54] Z., I, XXII.
Lecture II[1]
Part I
For, in the beginning, the world was "without form" and "void,"
things surrounded man; but they had no meaning. His senses
received probably the same number of impressions as they do now—
and perhaps more—but these impressions had no co-ordination and
no order. He could neither calculate them, reckon with them, nor
communicate[3] them to his fellows.
Before he could thus calculate, reckon with, and communicate the
things of this world, a vast process of simplification, co-ordination,
organization and ordering had to be undertaken, and this process,
however arbitrarily it may have been begun, was one of the first
needs of thinking man.
Everything had to be given some meaning, some interpretation, and
some place; and in every case, of course, this interpretation was in
the terms of man, this meaning was a human meaning, and this
place was a position relative to humanity.
Perhaps no object is adequately defined until the relation to it of
every creature and thing in the universe has been duly discovered
and recorded.[4] But no such transcendental meaning of a thing
preoccupied primeval man. All he wished was to understand the
world, in order that he might have power over it, reckon with it, and
communicate his impressions concerning it. And, to this end, the
only relation of a thing that he was concerned with was its relation
to himself. It must be given a name, a place, an order, a meaning—
however arbitrary, however fanciful, however euphemistic. Facts
were useless, chaotic, bewildering, meaningless, before they had
been adjusted,[5] organized, classified, and interpreted in
accordance with the desires, hopes, aims and needs of a particular
kind of man.
Thus interpretation was the first activity of all to thinking humanity,
and it was human needs that interpreted the world.[6]
The love of interpreting and of adjusting—this primeval love and
desire, this power of the sandboy over his castles; how much of the
joy in Life, the love of Life, and, at the same time, the sorrow in Life,
does not depend upon it! For we can know only a world which we
ourselves have created.[7]
There was the universe—strange and inscrutable; terrible in its
strangeness, insufferable in its inscrutability, incalculable in its
multifariousness. With his consciousness just awaking, a cloud or a
shower might be anything to man—a godlike friend or a savage foe.
The dome of blue behind was also prodigious in its volume and
depth, and the stars upon it at night horrible in their mystery.
What, too, was this giant's breath that seemed to come from
nowhere, and which, while it cooled his face, also bent the toughest
trees like straws? The sun and moon were amazing—the one
marvellously eloquent, communicative, generous, hot and
passionate: the other silent, reserved, aloof, cold, incomprehensible.
[8]
But there were other things to do, besides interpreting the stars, the
sun, the moon, the sea, and the sky above. There was the
perplexing multiplicity of changes and of tides in Life, to be mastered
and simplified. There was the fateful flow of all things into death and
into second birth, the appalling fact of Becoming and never-resting,
of change and instability, of bloom and of decay, of rise and of
decline. What was to be done?
It was impossible to live in chaos. And yet, in its relation to man
Nature was chaotic. There was no order anywhere. And, where there
is no order, there are surprises,[9] ambushes, lurking indignities. The
unexpected could jump out at any minute. And a masterful mind
abhors surprises and loathes disorder. His Will to Power is humiliated
by them. To man,—whether he be of yesterday, of to-day or of to-
morrow— unfamiliarity, constant change, and uncertainty, are
sources of great anxiety, great sorrow, great humiliation and
sometimes great danger. Hence everything must be familiarized,
named and fixed. Values must be definitely ascertained and
determined. And thus valuing becomes a biological need. Nietzsche
even goes so far as to ascribe the doctrine of causality to the
inherent desire in man to trace the unfamiliar to the familiar. "The
so-called instinct of causality," he says, "is nothing more than the
fear of the unfamiliar, and the attempt at finding something in it
which is already known."[10]
In the torrent and pell-mell of Becoming, some milestones must be
fixed for the purpose of human orientation. In the avalanche of
evolutionary changes, pillars must be made to stand, to which man
can hold tight for a space and collect his senses. The slippery soil of
a world that is for ever in flux, must be transformed into a soil on
which man can gain some foothold.[11]
Primeval man stood baffled and oppressed by the complexity of his
task. Facts were insuperable as facts; they could, however, be
overcome spiritually—that is to say, by concepts. And that they must
be overcome, man never doubted for an instant—he was too proud
for that. For his aim was not existence, but a certain kind of
existence—an existence in which he could hold his head up, look
down upon the world, and stare defiance even at the firmament.
And thus all humanity began to cry out for a meaning, for an
interpretation, for a scheme, which would make all these distant and
uncontrollable facts their property, their spiritual possessions. This
was not a cry for science, or for a scientific explanation, as we
understand it; nor was it a cry for truth in the Christian sense.[12]
For the bare truth, the bare fact, the bald reality of the thing was
obvious to everybody. All who had eyes to see could see it. All who
had ears to hear could hear it. And all who had nerves to feel could
feel it. If ever there was a time when there was a truth for all, this
was the time; and it was ugly, bare and unsatisfying. What was
wanted was a scheme of life, a picture of life, in which all these
naked facts and truths could be given some place and some human
significance—in fact, some order and arrangement, whereby they
would become the chattels of the human spirit, and no longer
subjects of independent existence and awful strangeness.[13] Only
thus could the dignity and pride of humanity begin to breathe with
freedom. Only thus could life be made possible, where existence
alone was not the single aim and desire.
"The purpose of 'knowledge,' "says Nietzsche, "in this case, as in the
case of 'good,' or 'beautiful,' must be regarded strictly and narrowly
from an anthropocentric and biological standpoint. In order that a
particular species may maintain and increase its power, its
conception of reality must contain enough which is calculable and
constant to allow of its formulating a scheme of conduct. The utility
of preservation—and not some abstract or theoretical need to
eschew deception—stands as the motive force behind the
development of the organs of knowledge.... In other words, the
measure of the desire for knowledge depends upon the extent to
which the Will to Power grows in a certain species: a species gets a
grasp of a given amount of reality in order to master it, in order to
enlist that amount into its service."[14]
And thus "the object was, not to know, but to schematize, to impose
as much regularity and form upon chaos as our practical needs
required."[15]
"The whole apparatus of knowledge," says Nietzsche, "is an
abstracting and simplifying apparatus—not directed at knowledge,
but at the appropriation of things."[16]
No physical thirst, no physical hunger, has ever been stronger than
this thirst and hunger, which yearned to make all that is unfamiliar,
familiar; or in other words, all that is outside the spirit, inside the
spirit.[17]
Life without food and drink was bad enough; but Life without
nourishment for this spiritual appetite, this famished wonder,[18] this
starving amazement, was utterly intolerable!
The human system could appropriate, and could transform into man,
in bone and flesh, the vegetation and the animals of the earth; but
what was required was a process, a Weltanschauung, a general
concept of the earth which would enable man to appropriate also
Life's other facts, and transform them into man the spirit. Hence the
so-called thirst for knowledge may be traced to the lust of
appropriation and conquest,[19] and the "will to truth" to a process
of establishing things, to a process of making things true and
lasting.... Thus truth is not something which is present and which
has to be found and discovered; it is something which has to be
created and which gives its name to a process, or better still, to the
"will to overpower."[20]
For what is truth? It is any interpretation of the world which has
succeeded in becoming the belief of a particular type of man.[21]
Therefore there can be many truths; therefore there must be an
order of rank among truths.
"Let this mean Will to Truth unto you," says Zarathustra, "that
everything be made thinkable, visible, tangible unto man!
"And what ye have called the world, shall have first to be created by
you:[22] your reason, your image, your will, your love shall the world
be! And, verily, for your own bliss, ye knights of Knowledge!"[23]
"The purpose was to deceive oneself in a useful way; the means
thereto was the invention of forms and signs, with the help of which,
the confusing multifariousness of Life could be reduced to a useful
and wieldly scheme."[24]
This was the craving. Not only must a meaning, a human meaning,
be given to all things, in order to subordinate them to man's power;
but Life itself must also be schematized and arranged. And, while all
humanity cried aloud for this to be done, it was humanity's artists
and higher men who set to and did it.[25]
[3] W. P., Vol. II, p. 72: "... Communication is necessary, and for it
to be possible, something must be stable, simple and capable of
being stated precisely."
[4] W. P., Vol. II, p. 65.
[5] Okakura-Kakuzo, The Book of Tea, p. 58: "Adjustment is Art."
[6] W. P., Vol. II, p. 13. See also Th. Gomperz, Greek Thinkers,
Vol. I, p. 25. Speaking of interpretation, he says: "And this
tendency was notably strengthened by the suspicious
circumstances of external life, which awoke the desire for
clearness, distinctness and a logical sequence of ideas."
[7] W. P., Vol. II, p. 21. See also Max Müller, Introduction to the
Science of Religion, pp. 198-207, T. I., Part 10, Aph. 19.
[8] Hegel, in his Vorlesungen über Æsthetik (Vol. I, p. 406), says:
"If we should wish to speak of the first appearance of symbolic
Art as a subjective state, we should remember that artistic
meditation in general, like religious meditation—or rather the two
in one—and even scientific research, took their origin in
wonderment."
[9] Hegel makes some interesting remarks on this point. See his
Vorlesungen über Æsthetik, Vol. I, p. 319. He shows that the
extreme regularity of gardens of the seventeenth century was
indicative of their owners' masterful natures.
[10] W. P., Vol. II, p. 58. See also p. 11: "to 'understand' means
simply this: to be able to express something new in the terms of
something old or familiar."
[11] W. P., Vol. II, p. 88.
[12] W. P., Vol. II, p. 26: "The prerequisite of all living things and
of their lives is: that there should be a large amount of faith, that
it should be possible to pass definite judgments on things, and
that there should be no doubt at all concerning values. Thus it is
necessary that something should be assumed to be true, not that
it is true."
[13] Felix Clay, The Origin of the Sense of Beauty, p. 95: "The
mind or the eye, brought face to face with a number of
disconnected and apparently different facts, ideas, shapes,
sounds or objects, is bothered and uneasy; the moment that
some central conception is offered or discovered by which they all
fall into order, so that their due relation to one another can be
perceived and the whole grasped, there is a sense of relief and
pleasure which is very intense."
[14] W. P., Vol. II, p. 12.
[15] W. P., Vol. II, p. 29.
[16] W. P., Vol. II, p. 24.
[17] W. P., Vol. II, p. 76. Hegel was also approaching this truth
when he said, in his introduction to the Vorlesungen über
Æsthetik (pp. 58, 59 of the translation of that Introduction by B.
Bosanquet): "Man is realized for himself by poetical activity,
inasmuch as he has the impulse, in the medium which is directly
given to him, and externally presented before him, to produce
himself. This purpose he achieves by the modification of external
things upon which he impresses the seal of his inner being. Man
does this in order, as a free subject, to strip the outer world of its