`
`
`
`Osborne McGraw-Hill
`2600 Tenth Street
`Berkeley, California 94710
`U.S.A.
`For information on translations or book distributors outside of the U.S.A.,
`please write to Osborne McGraw-Hill at the above address.
`C++ from the Ground Up
`Copyright © 1994 by McGraw-Hill. All rights reserved. Printed in the United .
`States of America. Except as permitted under the Copyright Act of 1976, no
`part of this publication may be reproduced or distributed in any form or by
`any means, or stored in a database or retrieval system, without the prior
`written permission of the publisher, with the exception that the program
`listings may be entered, stored, and executed in a computer system, but they
`may not be reproduced for publication.
`567890 DOC 998765
`ISBN 0-07-881969-5
`
`Publisher
`Lawrence Levitsky
`
`Acquisitions Editor
`Jeff Pepper
`Project Editor
`Nancy McLaughlin
`
`Technical Editor
`James Turley
`
`Proofreader
`Audrey Baer Johnson
`
`Computer Designer
`Marcela V. Hancik
`
`Quality Control Specialist
`Joe Scuderi
`Illustrator
`Rhys Elliott
`
`Interior Designer
`Marla Shelasky
`
`Indexer
`Sheryl Schildt
`
`Cover Design
`Ted Mader Associates
`
`Information has been obtained by Osborne McGraw-Hill from sources believed to be reliable. However, because of the
`possibility of human or mechanical error by our sources, Osborne McGraw-Hill, or others, Osborne McGraw-Hill does not
`guarantee the accuracy, adequacy, or completeness of any information and is not responsible for any errors or omissions or the
`results obtained from use of such information.
`
`Intf
`
`TlJ
`
`1 -
`
`PALO ALTO NETWORKS Exhibit 1030 Page 2
`
`
`
`round Up
`
`1 Overview of C++
`
`21
`
`:ies. (Of
`
`tse a
`
`tion's
`sed in
`:om
`
`.ier,
`run, and
`tions
`main()
`
`d library.
`
`terally
`)mpiler.
`tt
`
`lC().
`),
`te screen.
`
`cout <<" Inside myfunc() ";
`
`The program works like this. First, main() begins, and it executes the
`first cout statement. Next, main() calls myfunc( ). Notice how this is
`ach.ieved: the function's name, myfunc, appears, followed by parentheses,
`and finally by a semicolon. A function call is a C++ statement and, therefore,
`must end with a semicolon. Next, myfunc() executes its cout statement,
`and then returns to main() at the line of code immediately following the
`call. Finally, main() executes its second cout statement and then
`terminates. Hence, the output on the screen is this:
`
`2
`
`- prototype
`·x ares a
`-ction prior
`-¥ "ts first
`
`~-
`
`- argument
`sa value
`.assed to a
`-Action when
`: 1s called.
`
`In main( ) Inside myfunc( ) Back in main( )
`
`There is one other important statement in the preceding program:
`
`void myfunc(); II myfunc's prototype
`
`As the comment states, this is the prototype for myfunc( ). Although we
`will discuss prototypes in detail later in this book, a few words are necessary
`now. A function prototype declares the function prior to its definition. The
`prototype allows the compiler to know the function's return type, as well
`as the number and type of any parameters that the function may have. The
`compiler needs to know this information prior to the first time the function
`is called. This is why the prototype occurs before main().
`As you can see, myfunc() does not contain a return statement. The
`keyword void, which precedes both the prototype for myfunc() and its
`definition, formally states that myfunc() does not return a value. In C++,
`functions that don't return values are declared as void.
`
`Function Arguments
`It is possible to pass one or more values to a function. A value passed to a
`function is called an argument. In the programs that you have studied so
`far, none of the functions take any arguments. Specifically, neither main()
`nor myfunc() in the preceding examples have an argument. However,
`functions in C++ can have anywhere from no arguments at all to many
`arguments. The upper limit is determined by the compiler you are using, but
`the proposed C++ standard specifies that a function must be able to take at
`least 256 arguments.
`Here is a short program that uses one of C++'s standard library (i.e., built-in)
`functions, called abs( ), to display the absolute value of number. The abs()
`
`PALO ALTO NETWORKS Exhibit 1030 Page 3
`
`
`
`22
`
`C++ from the Ground Up
`
`A.n Overview of C
`
`function takes one argument, converts it into its absolute value, and returns
`the result.
`
`II Use the abs() function.
`#include <iostream.h>
`#include <stdlib.h> II required by abs()
`
`main()
`{
`
`cout << abs(-10);
`
`return 0;
`
`Here, the value -10 is passed as an argument to abs( ). The abs() function
`receives the argument that it is called with and returns its absolute value,
`which is 10 in this case. Although abs() takes only one argument, other
`functions can have several. The key point here is that when a function
`requires an argument, it is passed by specifying it between the parentheses
`that follow the function's name.
`The return value of abs() is used by the cout statement to display the absolute
`value of -10 on the screen. The reason this works is that whenever a function is
`part of a larger expression, it is automatically called so that its return value can
`be obtained. In this case, the return value of abs() becom~s the value of the
`right side of the<< operator and is, therefore, displayed on the screen.
`Notice one other thing about the preceding program: it also includes the
`header file stdlib.h. This is the header file required by abs( ). In general,
`whenever you use a library function, you must include its header file. The
`header file provides the prototype for the library function, among other things.
`When you create a function that takes one or more arguments, the variables
`that will receive those arguments must also be declared. These variables are
`called the parameters of the function. For example, the function shown next
`prints the product of the two integer arguments used in the call to the function.
`
`void mul(int x, int y)
`{
`
`cout << x * y << " ";
`
`Each time mul() is called, it will multiply the value passed to x by the value
`passed toy. Remember, however, that x andy are simply the operational
`variables that receive the values you use when calling the function.
`Consider the following short program, which illustrates how to call mul( ):
`
`A parameter
`is a variable
`defined by a
`function that
`receives an
`argument.
`
`II
`
`#in
`
`voi
`
`mai
`
`n
`n
`
`VOl
`
`Th
`is <
`rna
`an
`In
`
`If)
`fur
`as
`pa
`
`I
`
`af
`pa
`fuJ
`
`In
`seJ
`co
`
`F1
`
`PALO ALTO NETWORKS Exhibit 1030 Page 4
`
`
`
`;round Up
`
`Overview of C++
`
`d returns
`
`II A simple program that demonstrates mul().
`
`#include <iostream.h>
`
`void mul(int x, int y); II mul()'s prototype
`
`main()
`{
`
`mul(lO, 20);
`mul( 5, 6);
`mul( 8, 9);
`
`return 0;
`
`void mul(int x, int y)
`{
`
`cout << x * y << " ";
`
`2
`
`This program will print 200, 30, and 72 on the screen. When mul()
`is called, the C++ compiler copies the value of each argument into the
`matching parameter. That is, in the first call to mul( ), 10 is copied into x
`and 20 is copied into y. In the second call, 5 is copied into x and 6 into y.
`In the third call, 8 is copied into x and 9 into y .
`If you have never worked with a language that allows parameterized
`functions, then the preceding process may seem a bit strange. Don't worry;
`as you see more examples of C++ programs, the concept of arguments,
`parameters, and functions will become clear.
`
`R~~~~~~~:·. ·;~·~ ~::~· :~~~:~; ;:;:;~ ~~ :~; ~~;~: ·;~:~· i.s. ~:~~ ·t~ ·;~;1· ..
`
`a function. The variable that receives the value of an argument is called a
`parameter. In fact, functions that take arguments are called parameterized
`functions.
`
`In C++ functions, when there are two or more arguments, they are
`separated by commas. In this book, the term argument list will refer to
`comma-separated arguments. The argument list for mul() is x,y.
`
`Functions Returning Values
`Many of the C++ library functions that you will use return values. For
`example, the abs() function used earlier returned the absolute value of its
`argument. Also, functions you write may return values to the calling routine.
`
`mction
`ralue,
`>ther
`on
`1theses
`
`bsolute
`nction is
`tlue can
`>fthe
`
`;the
`teral,
`'.The
`: things.
`ariables
`les are
`rn next
`unction.
`
`1e value
`mal
`
`tul():
`
`PALO ALTO NETWORKS Exhibit 1030 Page 5
`
`
`
`You don't need to be an
`expert inC to learn C +-F
`
`All you need to learn C++ is C++ from the Ground Up, written by master
`C++ programmer Herb Schildt. With C++ fast becoming the professional(cid:173)
`programmer's language of choice, you'll want to start pro ramming inC++ as
`quickly as possible. Schildt understands this and gets righ to the point in this
`fast-paced, no-nonsense guide to learning C++.
`
`may already know, C++ is built on the foundation of C. For this reason, Schildt teaches you just the C
`As
`you'll need so you can quickly move on to the meat of C++, includink its object-oriented features. Schildt's clear
`instructions, practical examples, and v luable tips put this book in a class by itself.
`
`Written in the clear; uncompromising style that has made
`Schildt's programming books the choice of millions
`worldwide, C++ from the Ground Up starts with an
`overview of C++ and the general form of a C++ program.
`You'll then progress to the fundamentals of C++
`programming, including control statements, operators,
`variables, expressions, and data types.
`
`From this foundation, you'll then delve into:
`• Functions
`• Pointers and references
`• Classes and objects
`• Function and operator overloading
`• Constructors and destructors
`· Templates
`• Exception handling
`
`• Inheritance
`• Virtual functions
`· The C++ 1/ 0 system
`• The preprocessor
`• The principles behind Object-Oriented
`Programming (OOP)
`and much, much more.
`
`Unlike other C++ programming books, C++ from the
`Ground Up adheres to the draft ANSI C++ standard, so
`you will be learning the most up-to-date specification of
`C++, the version supported by all major C++ compilers.
`Therefore, what you learn today will still apply tomorrow.
`
`If you're ready to start using the power and versatility
`of C++-whether you program in DOS, Windows, OS/ 2,
`Unix, or any other operating system-Schildt's C++
`from the Ground Up is the ideal book for you.
`
`OsBORNE f.41
`Get Answers- Get Osborne
`For Accuracy. Quality. and Value
`
`ISBN 0-07-881969-5
`BYU BOOKSTORE
`C S290
`961
`
`. 11111~1'1111111~1'~ Ullllllllll
`
`l.Q 1 0-07-881969-5
`'
`.
`
`PALO ALTO NETWORKS Exhibit 1030 Page 6