PDF C++ How to Program Early Objects Version 9th Edition (eBook PDF) download
PDF C++ How to Program Early Objects Version 9th Edition (eBook PDF) download
https://ebookluna.com/product/ebook-pdf-java-how-to-program-early-
objects-10th/
ebookluna.com
https://ebookluna.com/product/ebook-pdf-java-how-to-program-early-
objects-11th-edition-by-paul-j-deitel/
ebookluna.com
https://ebookluna.com/download/c-how-to-program-ebook-pdf/
ebookluna.com
https://ebookluna.com/download/c-how-to-program-an-objects-natural-
approach-11e-ebook-pdf/
ebookluna.com
C How to Program, 9th Global Edition Deitel Paul - eBook
PDF
https://ebookluna.com/download/c-how-to-program-9th-global-edition-
ebook-pdf/
ebookluna.com
https://ebookluna.com/product/ebook-pdf-starting-out-with-c-early-
objects-9th-edition/
ebookluna.com
https://ebookluna.com/product/ebook-pdf-java-how-to-program-late-
objects-global-edition-11th-edition/
ebookluna.com
https://ebookluna.com/product/starting-out-with-c-early-objects-9th-
edition-by-tony-gaddis-ebook-pdf/
ebookluna.com
https://ebookluna.com/product/ebook-pdf-c-how-to-program-global-
edition-8th-by-paul-deitel/
ebookluna.com
Trademarks
DEITEL, the double-thumbs-up bug and DIVE INTO 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.
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.
UNIX is a registered trademark of The Open Group.
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 24–26 and Appendices F–K are PDF documents posted online at the book’s
Companion Website, which is accessible from www.pearsonhighered.com/deitel.
Preface xxi
8 Pointers 334
8.1 Introduction 335
8.2 Pointer Variable Declarations and Initialization 335
8.3 Pointer Operators 337
8.4 Pass-by-Reference with Pointers 339
8.5 Built-In Arrays 344
8.6 Using const with Pointers 346
8.6.1 Nonconstant Pointer to Nonconstant Data 347
8.6.2 Nonconstant Pointer to Constant Data 347
8.6.3 Constant Pointer to Nonconstant Data 348
8.6.4 Constant Pointer to Constant Data 349
8.7 sizeof Operator 350
8.8 Pointer Expressions and Pointer Arithmetic 353
8.9 Relationship Between Pointers and Built-In Arrays 355
8.10 Pointer-Based Strings 358
8.11 Wrap-Up 361
E Preprocessor 985
E.1 Introduction 986
E.2 #include Preprocessing Directive 986
E.3 #define Preprocessing Directive: Symbolic Constants 987
E.4 #define Preprocessing Directive: Macros 987
E.5 Conditional Compilation 989
E.6 #error and #pragma Preprocessing Directives 990
E.7 Operators # and ## 991
E.8 Predefined Symbolic Constants 991
E.9 Assertions 992
E.10 Wrap-Up 992
Index 999
Welcome to the C++ computer programming language and C++ How to Program, Ninth
Edition. This book presents leading-edge computing technologies. It’s appropriate for in-
troductory course sequences based on the curriculum recommendations of two key pro-
fessional organizations—the ACM and the IEEE. If you haven’t already done so, please
read the back cover and inside back cover—these capture the essence of the book concise-
ly. In this Preface we provide more detail for students, instructors and professionals.
At the heart of the book is the Deitel signature live-code approach—we present con-
cepts in the context of complete working programs followed by sample executions, rather
than in code snippets. Read the online Before You Begin section (www.deitel.com/
books/cpphtp9/cpphtp9_BYB.pdf) to learn how to set up your Linux-based, Windows-
based or Apple OS X-based computer to run the hundreds of code examples. All the source
code is available at www.deitel.com/books/cpphtp9 and www.pearsonhighered.com/
deitel. Use the source code we provide to run each program as you study it.
We believe that this book and its support materials will give you an informative, chal-
lenging and entertaining introduction to C++. As you read the book, if you have questions,
we’re easy to reach at [email protected]—we’ll respond promptly. For book updates,
visit www.deitel.com/books/cpphtp9, join our social media communities on Facebook
(www.deitel.com/DeitelFan), Twitter (@deitel), Google+ (gplus.to/deitel) and
LinkedIn (bit.ly/DeitelLinkedIn), and subscribe to the Deitel ® Buzz Online newsletter
(www.deitel.com/newsletter/subscribe.html).
C++11 Standard
The new C++11 standard, published in 2011, motivated us to write C++ How to Program,
9/e. Throughout the book, each new C++11 feature is marked with the “11” icon you see
here in the margin. These are some of the key C++11 features of this new edition:
• Conforms to the new C++11 standard. Extensive coverage of the new C++11 fea-
tures (Fig. 1).
• Code thoroughly tested on three popular industrial-strength C++11 compilers.
We tested the code examples on GNU™ C++ 4.7, Microsoft® Visual C++®
2012 and Apple® LLVM in Xcode® 4.5.
• Smart pointers. Smart pointers help you avoid dynamic memory management er-
rors by providing additional functionality beyond that of built-in pointers. We dis-
cuss unique_ptr in Chapter 17, and shared_ptr and weak_ptr in Chapter 24.
xxii Preface
Object-Oriented Programming
• Early-objects approach. The book introduces the basic concepts and terminology
of object technology in Chapter 1. You’ll develop your first customized classes
and objects in Chapter 3. Presenting objects and classes early gets you “thinking
about objects” immediately and mastering these concepts more thoroughly.1
• C++ Standard Library string. C++ offers two types of strings—string class ob-
jects (which we begin using in Chapter 3) and C strings. We’ve replaced most oc-
currences of C strings with instances of C++ class string to make programs more
robust and eliminate many of the security problems of C strings. We continue to
discuss C strings later in the book to prepare you for working with the legacy code
that you’ll encounter in industry. In new development, you should favor string
objects.
• C++ Standard Library array. Our primary treatment of arrays now uses the
Standard Library’s array class template instead of built-in, C-style, pointer-based
arrays. We still cover built-in arrays because they remain useful in C++ and so
that you’ll be able to read legacy code. C++ offers three types of arrays—arrays
and vectors (which we start using in Chapter 7) and C-style, pointer-based ar-
rays which we discuss in Chapter 8. As appropriate, we use class template array
instead of C arrays throughout the book. In new development, you should favor
class template array objects.
• Crafting valuable classes. A key goal of this book is to prepare you to build valu-
able classes. In the Chapter 10 case study, you’ll build your own custom Array
class, then in the Chapter 18 exercises you’ll convert it to a class template. You’ll
truly appreciate the class concept. Chapter 10 begins with a test-drive of class
template string so you can see an elegant use of operator overloading before you
implement your own customized class with overloaded operators.
• Case studies in object-oriented programming. We provide case studies that span
multiple sections and chapters and cover the software development lifecycle.
These include the GradeBook class in Chapters 3–7, the Time class in Chapter 9 and
the Employee class in Chapters 11–12. Chapter 12 contains a detailed diagram
and explanation of how C++ can implement polymorphism, virtual functions
and dynamic binding “under the hood.”
• Optional case study: Using the UML to develop an object-oriented design and C++
implementation of an ATM. The UML™ (Unified Modeling Language™) is the
1. For courses that require a late-objects approach, consider C++ How to Program, Late Objects Version,
which begins with six chapters on programming fundamentals (including two on control statements)
and continues with seven chapters that gradually introduce object-oriented programming concepts.
Other documents randomly have
different content
other, from that time called also Nazarenes, admitted with the
orthodox church the conception by the Holy Ghost. 48 But besides this
distinction there existed yet another. The most ancient ecclesiastic
writers, Justin Martyr and Irenæus for example, are acquainted with
those Ebionites only, who regarded Jesus as a naturally born man
first endowed with divine powers at his baptism. 49 In Epiphanius and
the Clementine Homilies, on the other hand, we meet with Ebionites
who had imbibed an element of speculative Gnosticism. This
tendency, which according to Epiphanius is to be dated from one
Elxai, has been ascribed to Essenic influence, 50 and traces of the
same have been discovered in the heresies referred to in the Epistle
to the Colossians; whereas the first class of Ebionites evidently
proceeded from common Judaism. Which form of opinion was the
earlier and which the later developed is not so easily determined;
with reference to the last detailed difference, it might seem, since
the speculative Ebionites are mentioned first by the Clementines and
Epiphanius, whilst Ebionites holding a simpler view are spoken of by
Justin and by Irenæus, that the latter were the earlier; nevertheless
as Tertullian already notices in his time the Gnosticising tendency of
the opinions of the Ebionites respecting Christ 51, and as the germ of
such views existed among the Essenes in the time of Jesus, the
more probable assumption is, that both opinions arose side by side
about the same period. 52 As little can it be proved with regard to the
other difference, that the views concerning Christ held by the
Nazarenes became first, at a later period, lowered to those of the
Ebionites 53; since the notices, partly confused and partly of late
date, of the ecclesiastical writers, may be naturally explained as
arising out of what may be called an optical delusion of the church,
which,—whilst she in fact made continual advances in the
glorification of Christ, but a part of the Jewish Christians remained
stationary,—made it appear to her as if she herself remained
stationary, whilst the others fell back into heresy.
[Contents]
§ 28.
NATURAL EXPLANATION OF THE HISTORY OF THE
CONCEPTION.
If, as appears from the foregoing statements, so many weighty
difficulties, philosophical as well as exegetical, beset the
supranaturalistic explanation, it is well worth while to examine
whether it be not possible to give an interpretation of the gospel
history which shall obviate these objections. Recourse has been had
to the natural explanation, and the two narratives singly and
conjointly have been successively subjected to the rationalistic mode
of interpretation.
[Contents]
§ 29.
The proneness of the ancient world to represent the great men and
benefactors of their race as the sons of the gods, has therefore been
referred to, in order to explain the origin of such a mythus. Our
theologians have accumulated examples from the Greco-Roman
mythology and history. They have cited Hercules, and the Dioscuri;
Romulus, and Alexander; but above all Pythagoras, 75 and Plato. Of
the latter philosopher Jerome speaks in a manner quite applicable to
Jesus: sapientiæ principem non aliter arbitrantur, nisi de partu
virginis editum. 76
From these examples it might have been inferred that the narratives
of the supernatural conception had possibly originated in a similar
tendency, and had no foundation in history. Here however the
orthodox and the rationalists are unanimous in denying, though
indeed upon different grounds, the validity of the analogy. Origen,
from a perception of the identical character of the two classes of
narratives, is not far from regarding the heathen legends of the sons
of the gods as true supernatural histories. Paulus on his side is more
decided, and is so logical as to explain both classes of narratives in
the same manner, as natural, but still as true histories. At least he
says of the narrative concerning Plato: it cannot be affirmed that the
groundwork of the history was a subsequent creation; it is far more
probable that Perictione believed herself to be pregnant by one of
her gods. The fact that her son became a Plato might indeed have
served to confirm that belief, but not to have originated it. Tholuck
invites attention to the important distinction that the mythi
concerning Romulus and others were formed many centuries after
the lifetime of these men: the mythi concerning Jesus, on the
contrary, must have existed shortly after his death. 77 He cleverly fails
to remember the narrative of Plato’s birth, since he is well aware
that precisely in that particular, it is a dangerous point. Osiander
however approaches the subject with much pathos, and affirms that
Plato’s apotheosis as son of Apollo did not exist till several centuries
after him 78; whereas in fact Plato’s sister’s son speaks of it as a
prevailing legend in Athens. 79 Olshausen, with whom Neander
coincides, refuses to draw any detrimental inference from this
analogy of the mythical sons of the gods; remarking that though
these narratives are unhistorical, they evince a general anticipation
and desire of such a fact, and therefore guarantee its reality, at least
in one historical manifestation. Certainly, a general anticipation and
representation must have truth for its basis; but the truth does not
consist in any one individual fact, presenting an accurate
correspondence with that notion, but in an idea which realizes itself
in a series of facts, which often bear no resemblance to the general
notion. The widely spread notion of a golden age does not prove the
existence of a golden age: so the notion of divine conceptions does
not prove that some one individual was thus produced. The truth
which is the basis of this notion is something quite different.
[Contents]
§ 30.
RELATION OF JOSEPH TO MARY—BROTHERS OF
JESUS.
Our Gospels, in the true spirit of the ancient legend, find it
unbecoming to allow the mother of Jesus, so long as she bore the
heavenly germ, to be approached or profaned by an earthly
husband. Consequently Luke (ii. 5 ) represents the connexion
between Joseph and Mary, prior to the birth of Jesus, as a
betrothment merely. And, as it is stated respecting the father of
Plato, after his wife had become pregnant by Apollo: ὅθεν καθαρὰν
γάμου φυλάξαι ἕως τῆς ἀποκυήσεως, 86 so likewise it is remarked of
Joseph in Matthew (i. 25 ): καὶ οὐκ ἐγίνωσκεν αὐτὴν (τὴν γυναῖκα
αὑτοῦ) ἕως οὖ ἔτεκε τὸν υἱὸν αὑτῆς τὸν πρωτότοκον. In each of
these kindred passages the Greek word ἕως (till) must evidently
receive the same interpretation. Now in the first quotation the
meaning is incontestably this:—that till the time of Plato’s birth his
father abstained from intercourse with his wife, but subsequently
assumed his conjugal rights, since we hear of Plato’s brothers. In
reference, therefore, to the parents of Jesus, the ἕως cannot have a
different signification; in each case it indicates precisely the same
limitation. So again the expression πρωτότοκος (firstborn) used in
reference to Jesus in both the Gospels (Matt. i. 25 , Luke ii. 7 )
supposes that Mary had other children, for as Lucian says: εἰ μὲν
πρῶτος, οὐ μόνος· εἰ δὲ μόνος, οὐ πρῶτος. 87 Even in the same
Gospels (Matt. xiii. 55 , [144]Luke viii. 19 ) mention is made of
ἀδελφοῖς Ἰησοῦ (the brothers of Jesus). In the words of Fritzsche:
Lubentissime post Jesu natales Mariam concessit Matthæus (Luke
does the same) uxorem Josepho, in hoc uno occupatus, ne quis ante
Jesu primordia mutuâ venere usos suspicaretur. But this did not
continue to satisfy the orthodox; as the veneration for Mary rose
even higher, she who had once become fruitful by divine agency was
not subsequently to be profaned by the common relations of life. 88
The opinion that Mary after the birth of Jesus became the wife of
Joseph, was early ranked among the heresies, 89 and the orthodox
Fathers sought every means to escape from it and to combat it.
They contended that according to the exegetical interpretation of
ἕως οὗ, it sometimes affirmed or denied a thing, not merely up to a
certain limit, but beyond that limitation and for ever; and that the
words of Matthew οὐκ ἐγίνωσκεν αὐτὴν ἕως οὗ ἔτεκε κ.τ.λ. excluded
a matrimonial connexion between Joseph and Mary for all time. 90 In
like manner it was asserted of the term πρωτότοκος, that it did not
necessarily include the subsequent birth of other children, but that it
merely excluded any previous birth. 91 But in order to banish the
thought of a matrimonial connexion between Mary and Joseph, not
only grammatically but physiologically, they represented Joseph as a
very old man, under whom Mary was placed for control and
protection only; and the brothers of Jesus mentioned in the New
Testament they regarded as the children of Joseph by a former
marriage. 92 But this was not all; soon it was insisted not only that
Mary never became the wife of Joseph, but that in giving birth to
Jesus she did not lose her virginity. 93 But even the conservation of
Mary’s virginity did not long continue to satisfy: perpetual virginity
was likewise required on the part of Joseph. It was not enough that
he had no connexion with Mary; it was also necessary that his entire
life should be one of celibacy. Accordingly, though Epiphanius allows
that Joseph had sons by a former marriage, Jerome rejects the
supposition as an impious and audacious invention; and from that
time the brothers of Jesus were degraded to the rank of cousins. 94
2. The age and authors of our histories of the birth of Jesus: Mary
and Joseph betrothed only; Joseph having no participation in the
conception of the child, and previous to his birth no conjugal
connexion with Mary.
The opinion that the ἀδελφοὶ (brothers) and ἀδελφαὶ Ἰησοῦ (sisters
of Jesus) mentioned in the New Testament, were merely half
brothers or indeed cousins, appears in its origin, as shown above,
together with the notion that no matrimonial connexion ever
subsisted between Joseph and Mary, as the mere invention of
superstition, a circumstance highly prejudicial to such an opinion. It
is however no less true that purely exegetical grounds exist, in virtue
of which theologians who were free from prejudice have decided,
that the opinion that Jesus actually had brothers is untenable. 99 Had
we merely the following passages—Matt. xiii. 55 , Mark vi. 3 ,
where the people of Nazareth, astonished at the wisdom of their
countryman, in order to mark his well known origin, immediately
after having spoken of τέκτων (the carpenter) his father, and his
mother Mary, mention by name his ἀδελφοὺς (brothers) James,
Joses, Simon, and Judas, together with his sisters whose names are
not given 100; again Matt. xii. 46 , Luke viii. 19 , when his mother
and his brethren come to Jesus; John ii. 12 , where Jesus journeys
with his mother and his brethren to Capernaum; Acts i. 14 , where
they are mentioned in immediate connexion with his mother—if we
had these passages only, we could not for a moment hesitate to
recognize here real brothers of Jesus at least on the mother’s side,
children of Joseph and Mary; not only on account of the proper
signification of the word ἀδελφὸς, but also in consequence of its
continual conjunction with Mary and Joseph. Even the passages—
John vii. 5 , in which it is remarked that his brethren did not believe
on Jesus, and Mark iii. 21 , compared with 31 , where, according to
the most probable explanation, the brothers of Jesus with his mother
went out to lay hold of him as one beside himself—furnish no
adequate grounds for relinquishing the proper signification of
ἀδελφὸς. Many theologians have interpreted ἀδελφοὺς Ἰησοῦ in the
last cited passage half brothers, sons of Joseph by a former
marriage, alleging that the real brothers of Jesus must have believed
on him, but this is a mere assumption. The difficulty seems greater
when we read in John xix. 26 f. that Jesus, on the cross, enjoined
John to be a son to his mother; an injunction it is not easy to regard
as suitable under the supposition that Mary had other children,
except indeed these were half-brothers and unfriendly to Jesus.
Nevertheless we can imagine the existence both of external
circumstances and of individual feelings which might have influenced
Jesus to confide his mother to John rather than to his brothers. That
these brothers appeared in company with his apostles after the
ascension (Acts i. 14 ) is no proof that they must have believed on
Jesus at the time of his death.
[Contents]
§ 31.
VISIT OF MARY TO ELIZABETH.
The angel who announced to Mary her own approaching pregnancy,
at the same time informed her (Luke i. 36 ) of that of her relative
Elizabeth, with whom it was already the sixth month. Hereupon Mary
immediately set out on a journey to her cousin, a visit which was
attended by extraordinary occurrences; for when Elizabeth heard the
salutation of Mary, the babe leaped in her womb for joy; she also
became inspired, and in her exultation poured [149]forth an address
to Mary as the future mother of the Messiah, to which Mary
responded by a hymn of praise (Luke i. 39–56 ).
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookluna.com