• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/349

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

349 Cards in this Set

  • Front
  • Back
batch processing
Early computers performing only one job or task at a time. The computer runs a single program at a while processing data in groups or batches. users generally submitted their jobs to a computer center on decks of punched cards and often had to wait hours or even day before printouts were returned to their desks.
Operating systems
developed to make using computers more convenient. Early operating systems smoothed and speeded up the transition between jobs, and hence increased the amount of work, or throughput, computers could process.
multiprogramming.
Multiprogramming involves the simultaneous operation of many jobs that are competing to share the computer’s resources. With early multiprogramming operating systems, users still submitted jobs on decks of punched cards and waited hours or days for results.
timesharing operating systems
Timesharing is a special case of multiprogramming in which users access the computer through terminals, typically devices with keyboards and screens. Dozens or even hundreds of users share the computer at once. The computer actually does not run all the user’s programs simultaneously. Rather, it runs a small portion of one user’s job, then moves on to service the next user, perhaps providing service to each user several times per second. Thus, the users’ programs appear to be running simultaneously. An advantage of timesharing is that user requests receive almost immediate responses.
In 1977, Apple Computer popularized
personal computing.
In 1981, IBM
the world’s largest computer vendor, introduced the IBM Personal Computer. This quickly legitimized personal computing in business, industry and government organizations, where IBM mainframes were heavily used.
computers were “stand-alone” units—people transported disks back and forth between them to share information this is called
sneakernet
local area networks (LANs
linked together in computer networks, sometimes over telephone lines
local area networks (LANs) within an organization. This led to the phenomenon of
distributed computing, in which an organization’s computing, instead of being performed only at some central computer installation, is distributed over networks to the sites where the organization’s work is performed.
The most powerful desktop machines
workstations
workstations
provide individual users with enormous capabilities. Information is shared easily across computer networks
servers
Information is shared easily across computer networks, where computers called servers (file servers, database servers, web servers, etc.)
client
a common data store that may be used by client computers distributed throughout the network,
Internet
a global network of computers
Social networking
sites, which keep track of users’ interpersonal relationships, have experienced extraordinary growth as part of Web 2.0. Sites such as MySpace, Facebook and LinkedIn rely heavily on network effects, attracting users only if their friends or colleagues are also members
community-generated content
Web 2.0 takes advantage of collective intelligence, the idea that collaboration will result in intelligent ideas. For example, wikis, such as the encyclopedia Wikipedia, allow users access to edit content. Tagging, or labeling content, is another key part of the collaborative theme of Web 2.0
Blogs
websites characterized by short postings in reverse chronological order

Many bloggers are recognized as part of the media, and companies are reaching out to the blogosphere, or blogging community, to track consumer opinions.
open source software
a style of developing software in which individuals and companies develop, maintain and evolve software in exchange for the right to use that software for their own purposes—has made it cheaper and easier to start Web 2.0 companies
Web services—software
software components accessible by applications (or other software components) over the Internet—are on the rise, favoring the “webtop” over the desktop in much new development
Mashups
combine two or more existing web applications to serve a new purpose and are dependent on open access to web services. For example, housingmaps.com is a mashup of Google Maps and real-estate listings on Craigslist.
Web 3.0
refers to the next movement in web development—one that realizes the full potential of the web. The Internet in its current state is a giant conglomeration of single websites with loose connections. Web 3.0 will resolve this by moving toward the Semantic Web
Semantic Web
or the “web of meaning”—in which the web becomes a giant database meaningfully searchable by computers.
three general types:
of programming languages
machine
Assembly and High - level
Any computer can directly understand only its own
machine language
machine language
Machine language is the “natural language” of a computer and as such is defined by its hardware design. [Note: Machine language is often referred to as object code. This term predates “object-oriented programming.”

Machine languages generally consist of strings of numbers (ultimately reduced to 1s and 0s) that instruct computers to perform their most elementary operations one at a time. Machine languages are machine dependent (i.e., a particular machine language can be used on only one type of computer). Such languages are cumbersome for humans,
Instead of using the strings of numbers that computers could directly understand, programmers began using English-like abbreviations to represent elementary operations. These abbreviations formed the basis of
assembly languages
Translator programs called assemblers
were developed to convert early assembly-language programs to machine language at computer speeds.
high-level languages
programmers still had to use many instructions to accomplish even the simplest tasks. To speed the programming process
high-level languages
were developed in which single statements could be written to accomplish substantial tasks
Translator programs called compilers
convert high-level language programs into machine language. High-level languages allow programmers to write instructions that look almost like everyday English and contain commonly used mathematical notations.
Interpreter programs
were developed to execute high-level language programs directly, although much more slowly.
C++ evolved from
C
C, which evolved from two previous programming languages
BCPL and B. BCPL
BCPL and B. BCPL was developed in 1967 by
Martin Richards as a language for writing operating systems software and compilers for operating systems.
The C language was evolved from B by
Dennis Ritchie at Bell Laboratories
ANSI) cooperated with the International Organization for Standardization (ISO) to standardize
C worldwide; the joint standard document was published in 1990 and is referred to as ANSI/ISO 9899: 1990.
C99 is the latest
ANSI standard for the C programming language
languages like Fortran for
mathematical applications
C99 also makes C more consistent with C++ by enabling polymorphism through type-generic mathematical functions and through the creation of a defined
boolean type
C++, an extension of C, was developed by
Bjarne Stroustrup in the early 1980s at Bell Laboratories
C++ provides a number of features that “spruce up” the C language, but more importantly, it provides capabilities for
object-oriented programming.
Objects are
essentially reusable software components that model items in the real world.
software reuse
Use existing pieces wherever possible. Called software reuse, this practice is central to object-oriented programming
Good Programming Practices
to help you write programs that are clearer, more understandable, more maintainable and easier to test and debug—or remove programming errors
Common Programming Errors
problems to watch out for and avoid),
Performance Tips
techniques for writing programs that run faster and use less memory
Portability Tips
techniques to help you write programs that can run, with little or no modification, on a variety of computers—these tips also include general observations about how C++ achieves its high degree of portability)
Error-Prevention Tips
techniques for removing programming errors—also known as bugs—from your programs and, more important, techniques for writing bug-free programs in the first place
dynamic content
interactivity, animations and the like
Microsystems in 1991 funded an internal corporate research project code-named Green. The project resulted in the development of a C++-based language that its creator, James Gosling, called Oak after an oak tree outside his window at Sun. It was later discovered that there already was a computer language called Oak. When a group of Sun people visited a local coffee shop, the name
Java was suggested and it stuck.
FORTRAN
FORmula TRANslator) was developed by IBM Corporation in the mid-1950s to be used for scientific and engineering applications that require complex mathematical computations. Fortran is still widely used, especially in engineering applications.
COBOL
COmmon Business Oriented Language) was developed in the late 1950s by computer manufacturers, the U.S. government and industrial computer users. COBOL is used for commercial applications that require precise and efficient manipulation of large amounts of data. Much business software is still programmed in COBOL.
People realized that software development was a more complex activity than they had imagined. Research in the 1960s resulted in the evolution of
structured programming
structured programming
a disciplined approach to writing programs that are clearer and easier to test, debug and modify than large programs produced with previous techniques.
Pascal
programming language by Professor Niklaus Wirth in 1971. Named after the seventeenth-century mathematician and philosopher Blaise Pascal, it was designed for teaching structured programming and rapidly became the preferred programming language in most colleges. Pascal lacks many features needed in commercial, industrial and government applications, so it was not widely accepted outside academia.
Ada programming language
was developed under the sponsorship of the U.S. Department of Defense (DoD) during the 1970s and early 1980s. Hundreds of separate languages were being used to produce the DoD’s massive command-and-control software systems. The DoD wanted a single language that would fill most of its needs. The Ada language was named after Lady Ada Lovelace, daughter of the poet Lord Byron. Lady Lovelace is credited with writing the world’s first computer program in the early 1800s (for the Analytical Engine mechanical computing device designed by Charles Babbage).
One important capability of Ada, called multitasking
allows programmers to specify that many activities are to occur in parallel.
The BASIC (Beginner’s All-purpose Symbolic Instruction Code) programming language
was developed in the mid-1960s at Dartmouth College as a means of writing simple programs. BASIC’s primary purpose was to familiarize novices with programming techniques. Microsoft’s Visual Basic language, introduced in the early 1990s to simplify the development of Microsoft Windows applications, has become one of the most popular programming languages in the world.
Microsoft’s latest development tools are part of its corporate-wide strategy for integrating the Internet and the web into computer applications. This strategy is implemented in Microsoft’s .NET platform
which provides the capabilities developers need to create and run computer applications that can execute on computers distributed across the Internet.
Microsoft’s three primary programming languages are
Visual Basic (based on the original BASIC), Visual C++ (based on C++) and Visual C# (a new language based on C++ and Java that was developed expressly for the .NET platform).
The C++ programming language, developed at AT&T by Bjarne Stroustrup in the early 1980s, is based on two languages
—C, which initially was developed at AT&T to implement the UNIX operating system in the early 1970s, and Simula 67, a simulation programming language developed in Europe and released in 1967
classes
object technology, the software entities created if properly designed, tend to be reusable on future projects
Some organizations report that the key benefit object-oriented programming gives them is not software reuse but, rather, that the software they produce is more
understandable, better organized and easier to maintain, modify and debug. This can be significant, because perhaps as much as 80 percent of software costs are associated not with the original efforts to develop the software, but with the continued evolution and maintenance of that software throughout its lifetime.
C++ systems generally consist of three parts
a program development environment, the language and the C++ Standard Library.
C++ programs typically go through six phases:
edit, preprocess, compile, link, load and execute.
Phase 1
consists of editing a file with an editor program (normally known simply as an editor). You type a C++ program (typically referred to as source code) using the editor, make any necessary corrections and save the program on a secondary storage device, such as your hard drive. C++ source code filenames often end with the .cpp, .cxx, .cc or .C extensions
In phase 2 and 3.
you give the command to compile the program. In a C++ system, a preprocessor program executes automatically before the compiler’s translation phase begins (so we call preprocessing phase 2 and compiling phase 3).
preprocessor directives
which indicate that certain manipulations are to be performed on the program before compilation. These manipulations usually include other text files to be compiled, and perform various text replacements.
Phase 4
is called linking. C++ programs typically contain references to functions and data defined elsewhere, such as in the standard libraries or in the private libraries of groups of programmers working on a particular project.
a linker
links the object code with the code for the missing functions to produce an executable image (with no missing pieces).
Phase 5
is called loading. Before a program can be executed, it must first be placed in memory. This is done by the loader, which takes the executable image from disk and transfers it to memory.
Phase 6
Finally, the computer, under the control of its CPU, executes the program one instruction at a time.
cin
the standard input stream; pronounced “see-in”), which is normally the keyboard, but cin can be redirected to another device.
cout
Data is often output to cout (the standard output stream; pronounced “see-out”), which is normally the computer screen, but cout can be redirected to another device. When we say that a program prints a result, we normally mean that the result is displayed on a screen. Data may be output to other devices, such as disks and hardcopy printers.
cerr
standard error stream referred to as cerr. The cerr stream (normally connected to the screen) is used for displaying error messages.
It is common for users to assign cout to a device other than the
screen while keeping cerr assigned to the screen, so that normal outputs are separated from errors.
runtime errors or execution-time errors. Fatal runtime errors
cause programs to terminate immediately without having successfully performed their jobs.
Nonfatal runtime errors
allow programs to run to completion, often producing incorrect results. [Note: On some systems, divide-by-zero is not a fatal error. Please see your system documentation.]
Write your C++ programs in a simple and straightforward manner. This is sometimes referred to as KIS
Keep it simple
Agile Software Development
is a set of methodologies that try to get software implemented quickly with fewer resources than previous methodologies.
Refactoring
involves reworking code to make it clearer and easier to maintain while preserving its functionality. It’s widely employed with agile development methodologies.
Design patterns
are proven architectures for constructing flexible and maintainable object-oriented software. The field of design patterns tries to enumerate those recurring patterns, encouraging software designers to reuse them to develop better quality software with less time, money and effort.
Game programming.
The computer game business is larger than the first-run movie business. College courses and even majors are now devoted to the sophisticated software techniques used in game programming.
Open source software
is a style of developing software in contrast to proprietary development that dominated software’s early years. With open source development, individuals and companies contribute their efforts in developing, maintaining and evolving software in exchange for the right to use that software for their own purposes, typically at no charge. Open source code generally gets scrutinized by a much larger audience than proprietary software, so bugs get removed faster. Open source also encourages more innovation.
Linux
is an open source operating system and one of the greatest successes of the open source movement.
MySQL
is an open source database management system
PHP
is the most popular open source server-side “scripting” language for developing Internet-based applications.
LAMP
is an acronym for the set of open source technologies that many developers used to build web applications—it stands for Linux, Apache, MySQL and PHP (or Perl or Python—two other languages used for similar purposes).
Ruby on Rails
combines the scripting language Ruby with the Rails web application framework developed by the company 37Signals.
Software has generally been viewed as a product
most software still is offered this way. If you want to run an application, you buy a software package from a software vendor. You then install that software on your computer and run it as needed. As new versions of the software appear, you upgrade your software, often at significant expense.
Software as a Service (SaaS)
the software runs on servers elsewhere on the Internet. When those servers are updated, all clients worldwide see the new capabilities; no local installation is needed. You access the service through a browser—these are quite portable, so you can run the same applications on different kinds of computers from anywhere in the world. Salesforce.com, Google, and Microsoft’s Office Live and Windows Live all offer SaaS.
The Boost C++ Libraries are free
open source libraries created by members of the C++ community. Boost has grown to over 70 libraries, with more being added regularly.
Smart pointers help you
avoid errors by providing additional functionality to standard pointers. This functionality typically strengthens the process of memory allocation and deallocation.
Technical Report 1 describes
the proposed changes to the C++ Standard Library, many of which are based on current Boost libraries.
Work on the new standard, currently referred to as
C++0x, began in 2003. The new standard is likely to be released in 2009. It will include changes to the core language and, most likely, many of the libraries in TR1.
Unified Modeling Language™ (UML™)
a graphical language that allows people who design object-oriented software systems to use an industry-standard notation to represent them.
objects
people, animals, plants, cars, planes, buildings, computers, monitors and so on. Humans think in terms of objects. Telephones, houses, traffic lights, microwave ovens and water coolers are just a few more objects we see around us every day.
two categories of objects
animate and inanimate.
Animate objects
are “alive” in some sense—they move around and do things.
Inanimate objects
do not move on their own.
Objects of both types, however, have some things in common. They all have
attributes ), and they all exhibit behaviors
attributes
.g., size, shape, color and weight
behaviors
a ball rolls, bounces, inflates and deflates; a baby cries, sleeps, crawls, walks and blinks; a car accelerates, brakes and turns; a towel absorbs water).
Object-oriented design (OOD) models software in terms similar to those that people use to
describe real-world objects. It takes advantage of class relationships, where objects of a certain class, such as a class of vehicles, have the same characteristics—cars, trucks, little red wagons and roller skates have much in common.
OOD takes advantage of
inheritance relationships, where new classes of objects are derived by absorbing characteristics of existing classes and adding unique characteristics of their own. An object of class “convertible” certainly has the characteristics of the more general class “automobile,” but more specifically, the roof goes up and down.
OOD also models communication between objects. Just as people
send messages to one another (e.g., a sergeant commands a soldier to stand at attention), objects also communicate via messages. A bank account object may receive a message to decrease its balance by a certain amount because the customer has withdrawn that amount of money.
OOD encapsulates
wraps
an object’s attributes and operations are
intimately tied together
Objects have the property of information hiding.
This means that objects may know how to communicate with one another across well-defined interfaces, but normally they are not allowed to know how other objects are implemented—implementation details are hidden within the objects themselves.
Programming in such a language is called object-oriented programming (OOP), and it allows computer programmers to
implement object-oriented designs as working software systems. Languages like C, on the other hand, are procedural, so programming tends to be action oriented.
In C, the unit of programming is the
function
In C++, the unit of programming is the
class from which objects are eventually instantiated (an OOP term for “created”). C++ classes contain functions that implement operations and data that implements attributes.
C++ programmers concentrate on creating their own
user-defined types called classes
user-defined types called classes
Each class contains data as well as the set of functions that manipulate that data and provide services to clients
Each class contains data as well as the set of functions that manipulate that data and provide services to clients
other classes or functions that use the class
The function components of a class are called
member functions (typically called methods in other object-oriented programming languages such as Java).
The nouns in a system specification help the
C++ programmer determine the set of classes from which objects are created that work together to implement the system.
Classes are to objects as blueprints
are to houses
a class is a
“plan” for building an object of the class. Just as we can build many houses from one blueprint, we can instantiate (create) many objects from one class.
associations.
Classes can have relationships with other classes. For example, in an object-oriented design of a bank, the “bank teller” class needs to relate to other classes, such as the “customer” class, the “cash drawer” class, the “safe” class, and so on.
Packaging software as classes makes it possible for future software systems to
reuse the classes.
Groups of related classes are often packaged as reusable
components
Ideally, you would go through this process and carefully review the design (or have your design reviewed by other software professionals) before writing any code. If this process involves analyzing and designing your system from an object-oriented point of view, it is called an
object-oriented analysis and design (OOAD) process.
Pseudocode is an
informal means of expressing program logic. It is not actually a programming language, but we can use it as a kind of outline to guide us as we write our code.
The UML is now the most widely used graphical representation scheme for modeling
object-oriented systems.
Pseudocode is
an informal means of expressing program logic
each line beginning with //
is a comment and c++ will not compile this.
A comment beginning with // is called a
single-line comment because it terminates at the end of the current line
cmments in may use C’s style in which a comment—possibly containing many lines—begins with /* and ends with
*/
#include <iostream>
is a preprocessor directive, which is a message to the C++ preprocessor Lines that begin with # are processed by the preprocessor before the program is compiled. This line notifies the preprocessor to include in the program the contents of the input/output stream header file <iostream>. This file must be included for any program that outputs data to the screen or inputs data from the keyboard using C++-style stream input/output.
Line 4 is simply a blank line. You use blank lines, space characters and tab characters (i.e., “tabs”) to make programs easier to read. Together, these characters are known as white space.
White-space characters are normally ignored by the compiler.
int main()
is a part of every C++ program. The parentheses after main indicate that main is a program building block called a function.
C++ programs begin executing at function
even if main is not the first function in the program. The keyword int to the left of main indicates that main “returns” an integer (whole number) value.
A keyword is a
word in code that is reserved by C++ for a specific use.
The left brace,
{ must begin the body of every function.
A corresponding right brace
} must end each function’s body.
std::cout << ”Welcome to C++!\n”;

instructs the computer to
perform an action—namely, to print the string of characters contained between the double quotation marks.
A string is
sometimes called a character string, a message or a string literal.
We refer to characters between double quotation marks simply as
strings NOTE: White-space characters in strings are not ignored by the compiler.
entire line 8, including std::cout, the << operator, the string ”Welcome to C++!\n” and the semicolon (;), is called a
statement
Every C++ statement must end with a
; semicolon (also known as the statement terminator).
Preprocessor directives (like #include) do not end with
a semicolon
standard output stream object
std::cout
The << operator is referred to as the
stream insertion operator. When this program executes, the value to the operator’s right, the right operand, is inserted in the output stream.
backslash (\) is called an
escape character. It indicates that a “special” character is to be output.
When a backslash is encountered in a string of characters, the next character is combined with the backslash to form an
escape sequence.
The escape sequence \n means
newline. It causes the cursor to move to the beginning of the next line on the screen
Omitting the semicolon at the end of a C++ statement is a
syntax error. :( not going to run.
A syntax error occurs when
the compiler encounters code that violates C++’s language rules (i.e., its syntax). The compiler normally issues an error message to help you locate and fix the incorrect code.
Syntax errors are also called
compiler errors, compile-time errors or compilation errors, because the compiler detects them during the compilation phase. You cannot execute your program until you correct all the syntax errors in it. As you’ll see, some compilation errors are not syntax errors.
return 0;
one of several means we’ll use to exit a function. When the return statement is used at the end of main, as shown here, the value 0 indicates that the program has terminated successfully.
" words displayed \n"
newline position the screen cursor to the beginning of the next line
\t
Horizontal tab
\r
Carriage return, position the screen cursor to the beginning of the current line; do not advance to the next line.
\a
Alert. Sound the system bell.
\\
Backslash. Used to print a backslash character.
\'
Single quote. Use to print a single quote character.
\"
Double quote. Used to print a double quote character.
stream extraction operator
>>, to obtain two integers typed by a user at the keyboard,
#include <iostream>// allows program to perform input and output
includes the contents of the <iostream> header file in the program.
int number1; // first integer to add
int number2; // second integer to add
int sum; // sum of number1 and number2
are declarations.
identifiers number1, number2 and sum are the names of
variables.
A variable is a location in the computer’s memory where a value can be stored for use by a program.
These declarations specify that the variables number1, number2 and sum are data of type int,
data of type int, meaning
that these variables will hold integer values, i.e., whole numbers such as 7, −11, 0 and 31914. All variables must be declared with a name and a data type before they can be used in a program.
Several variables of the same type may be declared in one declaration or in multiple declarations. We could have int sum1; int sum2; int sum; all three variables in one declaration as follows:
int number1, number2, sum;
If more than one name is declared in a declaration, the names are separated by commas (,); this is referred to as
comma-separated list.
data type double for specifying
real numbers,
the data type char for specifying
character data.
Real numbers are
numbers with decimal points, such as 3.4, 0.0 and −11.19.
A char variable may hold
only a single lowercase letter, a single uppercase letter, a single digit or a single special character (e.g., $ or *).
Types such as int, double and char are often called
fundamental types, primitive types or built-in types.
A variable name (such as number1) is any valid identifier that is not
a keyword.
An identifier is a series of characters consisting of letters, digits and underscores (_) that does not begin with a
digit.
C++ is case sensitive—uppercase and lowercase letters are different, so a1 and A1 are
different identifiers.
Choosing meaningful identifiers makes a program self-documenting
a person can understand the program simply by reading it rather than having to refer to manuals or comments.
Declarations of variables can be placed almost anywhere in a program, but they must appear
before their corresponding variables are used in the program.
Always place a blank line between a declaration and
adjacent executable statements
std::cout << ”Enter first integer: ”

prints the string Enter first integer: on the screen. This message is called a
prompt because it directs the user to take a specific action.
std::cin >> number1;

uses the input stream object cin (of namespace std) and the stream extraction operator, >>, to obtain a value from
the keyboard.
When the computer executes the preceding statement, it waits for the user to enter a value for variable number1.
std::cin>>number1;
The std::cout and std::cin stream objects facilitate interaction between the user and the computer. Because this interaction resembles a dialog, it is often called
conversational computing or interactive computing
sum = number1 + number2;
calculates the sum of the variables number1 and number2 and assigns the result to variable sum
assignment operator
=
Most calculations are performed in
assignment statements.
The = operator and the + operator are called
binary operators because each has two operands. In the case of the + operator, the two operands are number1 and number2.
std::endl
stream manipulator.
The name endl is an abbreviation for
“end line” and belongs to namespace std.
he std::endl stream manipulator outputs a
newline, then “flushes the output buffer.” This simply means that, on some systems where outputs accumulate in the machine until there are enough to “make it worthwhile” to display them on the screen, std::endl forces any accumulated outputs to be displayed at that moment
Using multiple stream insertion operators (<<) in a single statement is referred to as
concatenating, chaining or cascading stream insertion operations. It is unnecessary to have multiple statements to output multiple pieces of data.
Whenever a value is placed in a memory location, the value overwrites the previous value in that location; thus, placing a new value into a memory location is said to be
destructive.
when a value is read out of a memory location, the process is
nondestructive
arithmetic operators
P.E.M.D.A.S.
+
addition
-
subtraction
*
Multiplication
/ is what math condition
division
%
Modulus
Integer division
where both the numerator and the denominator are integers) yields an integer quotient.

Note that any fractional part in integer division is discarded (i.e., truncated)—no rounding occurs.
modulus operator, %, that yields the remainder after integer division
The expression x % y yields the remainder after x is divided by y. Thus, 7 % 4 yields 3 and 17 % 5 yields 2.
Arithmetic expressions in C++ must be entered into the computer in
straight-line form.
C++ applies the operators in arithmetic expressions in a precise sequence determined by the following rules of operator precedence
Parentheses

2.Multiplication, division and modulus operations are applied next. If an expression contains several multiplication, division and modulus operations, operators are applied from left to right.

3.Addition and subtraction operations are applied last. If an expression contains several addition and subtraction operations, operators are applied from left to right.
When we say that certain operators are applied from left to right, we are referring to the
associativity of the operators.
As in algebra, it is acceptable to place unnecessary parentheses in an expression to make the expression clearer.
These are called redundant parentheses.
cin vs. getline()
cin gets the first expression untill the first white space getline gets the entire string.
C++’s if statement that allows a program to take alternative action based on the truth or falsity of some condition. If the condition is met
the condition is true, the statement in the body of the if statement is executed.
If the condition is not met, i.e., the condition is false in an if statement
the body statement is not executed.
Conditions in if statements can be formed by using the
equality operators and relational operators
is equal to
==
is not equal to
!=
A fatal logic error causes
a program to fail and terminate prematurely.
A nonfatal logic error allows a
program to continue executing, but usually produces incorrect results.
using std::cin;
using std::cout;
using std::endl;
are using declarations that eliminate the need to repeat the std:: prefix
Once we insert using std::cin; using std::cout; using std::end; you can
we can write cout instead of std::cout, cin instead of std::cin and endl instead of std::endl
a function belonging to a class is
a member function.
that just as many cars can be built from the same engineering drawing
many objects can be built from the same class.
Similarly, you send messages to an object—each message is known as a
member-function call
Attributes are specified by the class’s
data members.
we must tell the compiler what member functions and data members belong to the class. This is known as
defining a class
By convention, the name of a user-defined class begins with
a capital letter, and for readability, each subsequent word in the class name begins with a capital letter. This capitalization style is often referred to as camel case, because the pattern of uppercase and lowercase letters resembles the silhouette of a camel.
Every class’s body is enclosed in a pair of left and right
braces
The class definition terminates with
a semicolon ;
access-specifier label
public or privat
public is an access specifier, define member function displayMessage.
This member function appears after access specifier public: to indicate that the function is “available to the public”—that is, it can be called by other functions in the program (such as main), and by member functions of other classe
Access specifiers are always followed by a
colon :
When you define a function, you must specify a return type to indicate the type of the value returned by the function when it completes its task
void to the left of the function name displayMessage is the function’s return type. Return type void indicates that displayMessage will not return

(i.e., give back) any data to its calling function
function names begin with a lowercase first letter and all subsequent words in the name begin with
a capital letter
The parentheses after the member function name indicate that this is
a function
An empty set of parentheses,
indicates that this member function does not require additional data to perform its task
The name of the member function, displayMessage, follows the return type
By convention, function names begin with a lowercase first letter and all subsequent words in the name begin with a capital letter
a user-defined type
We tell the compiler what GradeBook is by including the class definition
You can define new class types as needed; this is one reason why C++ is known as an
extensible language
myGradeBook.displayMessage();
calls the member function displayMessage

using variable myGradeBook followed by the dot operator (.), the function name displayMessage and an empty set of parentheses.
Variables declared in a function definition’s body are known as
local variables and can be used only from the line of their declaration in the function to the immediately following closing right brace (}).
A local variable must be declared before it can be used in .
a function
A local variable cannot be accessed outside the
function in which it is declared. When a function terminates, the values of its local variables are lost.
Attributes are represented as variables in a class definition. Such variables are called
data members and are declared inside a class definition but outside the bodies of the class’s member-function definitions. Each object of a class maintains its own copy of its attributes in memory.
Member function setCourseName
stores a course name in a GradeBook data member.
Member function getCourseName
obtains the course name from that data member.
Most data-member declarations appear after the
access-specifier label
A benefit of making courseName a data member is that all the member functions of the class (in this case, class GradeBook)
can manipulate any data members that appear in the class definition (in this case, courseName).
Variables or functions declared after access specifier private
are accessible only to member functions of the class for which they are declared.
data members should be declared
private
member functions
should be declared public.
The default access for class members is
private
empty string
i.e., a string that does not contain any characters. Nothing appears on the screen when an empty string is displayed.
A class’s private data members can be manipulated only by member functions of that
class
Classes often provide public member functions to allow clients of the class to set (i.e., assign values to) or get (i.e., obtain the values of) private data members.
set or get private data members.

the names of these member functions need not begin with set or get, but this naming convention is common.
set
(i.e., assign values to)
get functions
(i.e., obtain the values of)
Note that set functions are also sometimes called
mutators (because they mutate, or change, values),
get functions are also sometimes called
accessors (because they access values).
Providing public set and get functions allows clients of a class to access the hidden data, but only
indirectly
The set and get functions allow a client to interact with an object, but
the object’s private data remains safely encapsulated (i.e., hidden) in the object itself.
The set and get functions of a class also should be used by other member functions within the class to manipulate the class’s private data, although
these member functions can access the private data directly.
UML class diagram for the version of class GradeBook as an attribute in the
in the middle compartment
The UML represents data members as attributes by listing the attribute name, followed by a
colon : and the attribute type.
The UML type of attribute courseName is String, which corresponds to string in C++. Data member courseName is private in C++, so the class diagram lists a .
minus sign (–) in front of the corresponding attribute’s name

The minus sign in the UML is equivalent to the private access specifier in C++.
the UML 's Class GradeBook contains three public member functions, so the class diagram lists three operations in the
third compartment
The UML indicates the return type of an operation by placing a colon and the return type after
the parentheses following the operation name.
Each class you declare can provide a constructor that can be
used to initialize an object of the class when the object is created.
A constructor is a
special member function that must be defined with the same name as the class, so that the compiler can distinguish it from the class’s other member functions.
An important difference between constructors and other functions is that constructors cannot return values, so
they cannot specify a return type
Normally, constructors are declared
public. The term “constructor” is often abbreviated as “ctor” in the literature—we generally avoid abbreviations.
C++ requires a constructor call for each object that is created which
helps ensure that each object is initialized before it is used in a program
The constructor call occurs implicitly when the object
is created
If a class does not explicitly include a constructor, the compiler provides a
default constructor—that is, a constructor with no parameters.
the constructor has the same name as its
class, GradeBook.
A constructor specifies in its parameter list the data it requires to
perform its task
Two Ways to Provide a Default Constructor for a Class

Any constructor that takes no arguments is called a default constructor. A class gets a default constructor in one of two ways:
1. The compiler implicitly creates a default constructor in a class that does not define a constructor. Such a default constructor does not initialize the class’s data members, but does call the default constructor for each data member that is an object of another class.

2. You explicitly define a constructor that takes no arguments. Such a default constructor will perform the initialization specified by you and will call the default constructor for each data member that is an object of another class.
If you define a constructor with arguments, C++ will not implicitly create a
default constructor for that class
The UML class diagram models constructors in the
third compartment of a class in a class diagram
To distinguish a constructor from a class’s operations, the UML places the word
“constructor” between guillemets
we can reuse C++ Standard Library type string in any C++ program by including the
header file <string> in the program
.cpp file
as a source-code file
When building an object-oriented C++ program, it is customary to define reusable source code (such as a class) in a file that by convention has a
.h file name extension known as the header file.
Programs use #include preprocessor directives to include
header files and take advantage of reusable software components
To help you prepare for the larger programs you’ll encounter later in this book and in industry, we often use a separate source-code file containing function main to test our classes (this is called
a driver program
A header file such as GradeBook.h cannot be used to begin program execution, because it does not contain a
main function.
By including GradeBook.h in line 7, we give the compiler access to the information it needs to determine the
size of a GradeBook object and to determine whether objects of the class are used correctly
Normally, a program’s source-code files and user-defined header files are placed in the same
directory.
When the preprocessor encounters a header file name in quotes (e.g., ”GradeBook.h”), the preprocessor attempts
to locate the header file in the same directory as the file in which the #include directive appears.
Notice that each member-function name in the function headers is preceded by the class name and ::, which is known as the binary scope resolution operator.
This “ties” each member function to the GradeBook class definition, which declares the class’s member functions and data members. Without “GradeBook::” preceding each function name, these functions would not be recognized by the compiler as member functions of class GradeBook—the compiler would consider them “free” or “loose” functions, like main.
Standard class string provides member function substr (short for “substring”) that returns
a new string object created by copying part of an existing string object.
A function prototype is a declaration of a function that tells the compiler
the function’s name, its return type and the types of its parameters.
Normally, statements in a program execute one after the other in the order in which they are written. This is called
sequential execution.
Various C++ statements we’ll soon discuss enable you to specify that the next statement to execute may be other than the next one in sequence. This is called
transfer of control.
which allows you to specify a transfer of control to one of a wide range of possible destinations in a program (creating what is often called “spaghetti code”).
goto statement
Böhm and Jacopini’s work demonstrated that all programs could be written in terms of only three control structures, namely
the sequence structure, the selection structure and the repetition structure. The term “control structures” comes from the field of computer science.
Unless directed otherwise, the computer executes C++ statements one after the other in the order in which they are written—
that is, in sequence.
C++ provides three types of selection statements
if, if...else, switch selection statement
The if selection statement either performs
(selects) an action if a condition (predicate) is true or skips the action if the condition is false.
The if…else selection statement performs an action if a condition
is true or performs a different action if the condition is false.
The switch selection statement performs one of many different actions, depending
on the value of an integer expression.
The if selection statement is a single-selection statement because
it selects or ignores a single action
The if…else statement is called a double-selection statement because
it selects between two different actions (or groups of actions)
The switch selection statement is called a multiple-selection statement because
it selects among many different actions (or groups of actions).
C++ provides three types of repetition statements
while, do..while, for
The while and for statements perform the action (or group of actions) in their bodies zero or more times—
if the loop-continuation condition is initially false, the action (or group of actions) will not execute.
The do…while statement performs the action (or group of actions) in its body
at least once.
Just as a block can be placed anywhere a single statement can be placed, it is also possible to have no statement at all—called a null statement (or an empty statement ). represented by
The null statement is represented by placing a semicolon (;) where a statement would normally be.
To include several statements in the body of an if or in either part of an if…else, enclose the statements
in braces
A set of statements contained within a pair of braces is called a
compound statement or a block.
The C++ compiler always associates an else with the immediately preceding if unless told to do otherwise by the placement of braces ({ and }). This behavior can lead to what is referred to as the
dangling-else problem
A repetition statement (also called a looping statement or a loop) allows you to specify that a program should repeat an action while
some condition remains true.
The if single-selection statement performs an indicated action only when the condition is true; otherwise the action is skipped.
is true; otherwise the action is skipped.
The if…else double-selection statement allows you to specify an action to perform when
when the condition is true and a different action to perform when the condition is false.
Nested if…else statements test for multiple cases
by placing if…else selection statements inside other if…else selection statements.
A repetition statement (also called a looping statement or a loop) allows you to specify that a program should repeat an action while
some condition remains true
Using a loop’s counter-control variable in a calculation after the loop often causes a common logic error called an
off-by-one erro
the cast operator static_cast< double >( total ) to create a temporary floating-point copy of its operand in parentheses—total. Using a cast operator in this manner is called
explicit conversion. The value stored in total is still an integer.
An increment or decrement operator that is prefixed to (placed before) a variable is referred to as
the prefix increment or prefix decrement operator
C++ also provides two unary operators for adding 1 to or subtracting 1 from the value of a numeric variable.
These are the unary increment operator, ++, and the unary decrement operator, --
preincrement ++a
Increment a by 1, then use the new value of a in the expression in which a resides.
postincrement a++
Use the current value of a in the expression in which a resides, then increment a by 1.
predecrement --b
Decrement b by 1, then use the new value of b in the expression in which b resides.
postdecrement b--
Use the current value of b in the expression in which b resides, then decrement b by 1.
Using the prefix increment (or decrement) operator to add (or subtract) 1 from a variable is known as
preincrementing (or predecrementing) the variable
Using the postfix increment (or decrement) operator to add (or subtract) 1 from a variable is known
as postincrementing (or postdecrementing) the variable
passes = passes + 1;
failures = failures + 1;
studentCounter = studentCounter + 1;
can also be written as
passes += 1;
failures += 1;
studentCounter += 1;
passes = passes + 1;
failures = failures + 1;
studentCounter = studentCounter + 1;

can be written as

with prefix increment operators as
++passes;
++failures;
++studentCounter;
passes = passes + 1;
failures = failures + 1;
studentCounter = studentCounter + 1;

can be written as

or with postfix increment operators as
passes++;
failures++;
studentCounter++;
Counter-controlled repetition requires 4 things
1. the name of a control variable (or loop counter)

2. the initial value of the control variable

3. the loop-continuation condition that tests for the final value of the control variable

4. the increment (or decrement) by which the control variable is modified each time through the loop.
The general form of the for statement is
for (initialization; loopContinuationCondition; increment )
statement
If the initialization expression in the for statement header declares the control variable (i.e., the control variable’s type is specified before the variable name), the control variable can be used only in
the body of the for statement
the control variable will be unknown outside the for statement. This restricted use of the control variable name is known as the
variable’s scope.
the initialization and increment expressions can be comma-separated lists of expressions. The commas, as used in these expressions, are
comma operators, which guarantee that lists of expressions evaluate from left to right.
nonparameterized stream manipulator
fixed.
the formatting specified by the parameterized stream manipulators
setprecision and setw
The stream manipulator setw( 4 ) specifies
that the next value output should appear in a field width of 4—i.e., cout prints the value with at least 4 character positions.
To indicate that values should be output left justified, simply output nonparameterized stream manipulator c
left (found in header <iostream>).
C++ provides the switch multiple-selection statement to perform many different actions based on
the possible values of a variable or expression.
C++ provides the types short (an abbreviation of short int) and long (an abbreviation of long int). The minimum range of values for short integers is
−32,768 to 32,767.
or the vast majority of integer calculations, long integers are sufficient. The minimum range of values for long integers
is −2,147,483,648 to 2,147,483,647.
The break statement, when executed in a while, for, do…while or switch statement, causes immediate
exit from that statement
The continue statement, when executed in a while, for or do…while statement,
skips the remaining statements in the body of that statement and proceeds with the next iteration of the loop.
Suppose that we wish to ensure that two conditions are both true before we choose a certain path of execution. In this case, we can use the
&& (logical AND) operator
to ensure at some point in a program that either or both of two conditions are true before we choose a certain path of execution. In this case, we use the
|| operator,
= used to
assign values going from right to left
== used to
set values equal to another not assign example used in if statment.
functions are sometimes referred to as
user-defined functions or programmer-defined functions.
A function prototype (also called a function declaration) tells the compiler the
name of a function, the type of data returned by the function, the number of parameters the function expects to receive, the types of those parameters and the order in which the parameters of those types are expected.
n enumeration, introduced by the keyword enum and followed by a type
name (in this case, Status), is a set of integer constants represented by identifiers.
The values of these enumeration constants start at
0, unless specified otherwise, and increment by 1.
Use only uppercase letters in the names of
enumeration constants. This makes these constants stand out in a program and reminds you that enumeration constants are not variables.
Two ways to pass arguments to functions in many programming languages are
pass-by-value and pass-by-reference.
When an argument is passed by value,
a copy of the argument’s value is made and passed (on the function call stack) to the called function. Changes to the copy do not affect the original variable’s value in the caller. This
One disadvantage of pass-by-value is that, if a large data item is being passed,
copying that data can take a considerable amount of execution time and memory space.
To indicate that a function parameter is passed by reference, simply follow the parameter’s type in the function prototype by an
ampersand &
With pass-by-reference, the caller gives the called function the ability
to access the caller’s data directly, and to modify that data if the called function chooses to do so.