Microsoft Visual C NET Chapter 1 1st Edition Don Gosselin instant download
Microsoft Visual C NET Chapter 1 1st Edition Don Gosselin instant download
https://ebookname.com/product/microsoft-visual-c-net-
chapter-1-1st-edition-don-gosselin/
https://ebookname.com/product/microsoft-visual-c-
net-2003-developer-s-cookbook-1st-edition-mark-schmidt/
https://ebookname.com/product/mastering-visual-c-net-1st-edition-
jason-price/
https://ebookname.com/product/expert-c-cli-net-for-visual-c-
programmers-1st-edition-marcus-heege/
https://ebookname.com/product/the-girlhood-of-shakespeare-s-
heroines-volume-1-in-a-series-of-fifteen-tales-1st-edition-mary-
cowden-clarke/
Handbook of Ecotoxicology 2nd Edition David J. Hoffman
https://ebookname.com/product/handbook-of-ecotoxicology-2nd-
edition-david-j-hoffman/
https://ebookname.com/product/differential-geometry-applied-to-
dynamical-systems-world-scientific-series-on-nonlinear-science-
series-a-jean-marc-ginoux/
https://ebookname.com/product/minority-students-in-east-asia-
government-policies-school-practices-and-teacher-responses-1st-
edition-joann-phillion/
https://ebookname.com/product/neuroinflammation-new-insights-
into-beneficial-and-detrimental-functions-1st-edition-samuel-
david/
https://ebookname.com/product/frommer-s-irreverent-guide-to-
rome-2nd-edition-sylvie-hogg/
Powerful and Brutal Weapons Nixon Kissinger and the
Easter Offensive 1St Edition Edition Stephen P.
Randolph
https://ebookname.com/product/powerful-and-brutal-weapons-nixon-
kissinger-and-the-easter-offensive-1st-edition-edition-stephen-p-
randolph/
Licensed to: iChapters User
A4535_FM 2/9/09 9:06 AM Page ii
Licensed to: iChapters User
Course Technology
20 Channel Center Street
Boston, MA 02210
USA
Purchase any of our products at your local college store or at our preferred
online store www.ichapters.com
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
1 Chapter A4535 25000 4/22/02 2:42 PM Page 1
Licensed to: iChapters User
CHAPTER
1
INTRODUCTION TO
PROGRAMMING AND
VISUAL C++
In this chapter you will learn about:
♦ Computer programming and programming languages
♦ C/C++ programming
♦ Logic and debugging
♦ Creating a new project in Visual C++
♦ The Visual Studio IDE
♦ Managing the solution
♦ Visual C++ Help
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
1 Chapter A4535 25000 4/22/02 2:42 PM Page 2
Licensed to: iChapters User
When you start a program and provide it with the data it needs to function, you are
running, or executing, the program. To develop the comparison to an automobile a
little further, you can think of the driver as the program that operates the automobile.
The gas and oil that the automobile needs to operate are its data. Figure 1-1 illustrates
the concept of how hardware, software, and data all work together to execute an auto-
mobile program.
Gasoline
(data)
Driver
(computer program)
Automobile
Motor Oil
(computer hardware)
(data)
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
1 Chapter A4535 25000 4/22/02 2:42 PM Page 3
Licensed to: iChapters User
0
1
0
0
1
0
0
1
1
1
0
0
1
0
0
1
1
1
1
0 0 1 1 0 0 1 1 0
1 0 0 0 0 1 1 1 1
0 0 1 0 1 1 0 1 0
1 0 0 1 1 1 1 0 0
0 0 1 1 0 1 0 0 1
Writing a program in machine language is very difficult because you must understand
how the exact placement and combination of 1s and 0s will affect your program.
Assembly languages provide an easier (although still challenging) method of controlling
a computer’s on and off switches. Assembly languages perform the same tasks as
machine languages, but use simplified names of instructions instead of 1s and 0s.To get
an idea of how difficult it can be to program with assembly languages, examine the fol-
lowing assembly code, which only performs some simple numeric calculations.
Main proc
ƒƒƒmov ax, dseg
Aƒƒinteger ?
Bƒƒinteger ?
Cƒƒinteger ?
cseg segment para public ‘code’
assume cs:cseg, ds:dseg
Main proc
ƒƒƒmov ax, dseg
ƒƒƒmov ds, ax
ƒƒƒmov es, ax
ƒƒƒmov A, 3
ƒƒƒmov B, -2
ƒƒƒmov C, 254
ƒƒƒmov ax, A
ƒƒƒadd ax, B
ƒƒƒmov C, ax
Machine languages and assembly languages are known as low-level languages because
they are the programming languages that are closest to a computer’s hardware. Each type
of central processing unit (CPU) contains its own internal machine language and
assembly language. To write programs in machine language, a programmer must know
the specific machine language and assembly language for the type of CPU on which a
program will run. Because each CPU’s machine language and assembly language is
unique, it is difficult to translate low-level languages from one CPU to another.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
1 Chapter A4535 25000 4/22/02 2:42 PM Page 4
Licensed to: iChapters User
easier to understand than machine or assembly language code because you use words
that more clearly describe the task being performed. Examples of high-level languages
include C++, BASIC, and COBOL. To understand the difference between low-level
languages and high-level languages, consider the following assembly language code that
adds two numbers, and then assigns the result to a variable named C:
mov A, 3
mov B, 2
add A, B
mov C, A
Although easier than machine language, the above assembly language code is still diffi-
cult to understand. In comparison, the same task is accomplished in a high-level language
using a much simpler statement. For example, the following C++ statement performs the
same addition task and assigns the result to a variable named C: int C = 3 + 2;.The
syntax in C++ is much easier to understand than the syntax in assembly language.
Another advantage to high-level programming languages is that they are not CPU-specific,
as are machine and assembly languages.This means that a program you write in a high-level
programming language will run on many different types of CPUs, regardless of their machine
languages or assembly languages. However, in order to run, programs written in high-level
languages must first be translated into a low-level language using a program called a
compiler. A compiler translates programming code into a low-level format.You need to
compile a program only once when you are through writing it or after editing an existing
program.When you execute the program, you actually execute the compiled, low-level for-
mat of the program. However, each time you make any changes to an existing program, you
must recompile it before the new version of the program will execute.
Procedural Programming
One of the most common forms of programming in high-level languages is called pro-
cedural programming. In procedural programming, computer instructions are often
grouped into logical units called procedures. In C++ programming, procedures are
referred to as functions. Each line in a procedural program that performs an individual
task is called a statement. For example, a checkbook program may contain a series of
statements grouped as a function named balanceCheckbook() that balances a check-
book. Another function named sumDeposits() may be used to calculate the total of all
deposits made during a single period. A single procedural program may contain hun-
dreds of variables and thousands of statements and functions.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
1 Chapter A4535 25000 4/22/02 2:42 PM Page 5
Licensed to: iChapters User
One of the most important aspects of procedural programming is that it allows you to tem-
porarily store pieces of data in computer memory locations called variables.The informa-
tion contained in a specific variable often changes. For example, you may have a program
that creates a variable containing the current time. Each time the program runs, the time is
different, so the value varies.The value of a variable often changes during the course of pro-
gram execution. For example, a payroll program might assign employee names to a variable
named employeeName. The memory location referenced by the variable employeeName
might contain different values (a different value for every employee of the company) at dif-
ferent times. Another form of data that you can store in computer memory locations is a
constant. A constant contains information that does not change during the course of pro-
gram execution.You can think of a constant as a variable with a constant value. A common
example of a constant is the value of pi (π), which represents the ratio of the circumference
of a circle to its diameter.The value of pi never changes from the constant value of 3.141592.
The statements within a procedural program usually execute in a linear fashion, one
right after the other. Figure 1-2 displays a simple procedural program written in BASIC
that calculates and prints the average of the numbers 1, 2, and 3.The first two statements
in the program create variables named SUM and COUNT. During the course of pro-
gram execution, the numbers 1, 2, and 3 are added to the SUM variable.The COUNT
variable maintains a record of how many numbers are assigned to the SUM variable.
Finally, the average is calculated using the statement SUM / COUNT. The last state-
ment, which begins with PRINT, prints the result of the program to the screen.
LET SUM = 0
LET COUNT = 0
LET SUM = SUM + 1
LET COUNT = COUNT + 1
LET SUM = SUM + 2
LET COUNT = COUNT + 1
LET SUM = SUM + 3
LET COUNT = COUNT + 1
LET AVERAGE = SUM / COUNT
PRINT “The average is “; AVERAGE
Object-Oriented Programming
Procedural-based programs are self-contained; most code, such as variables, statements,
and functions, exists within the program itself. For example, you may have written a
small business program that calculates accounts receivable and accounts payable. To add
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
1 Chapter A4535 25000 4/22/02 2:42 PM Page 6
Licensed to: iChapters User
to the program a new function that calculates the interest on a loan, you must include
all the required code within the accounting program, using variables, statements, and
functions. If you want to use the interest calculation code in another program, you must
copy all of its statements into the new program or recreate it from scratch.
Object-oriented programming takes a different approach. Object-oriented
programming (OOP) refers to the creation of reusable software objects that can be
easily incorporated into another program. Reusable software objects are often referred
to as components. For example, you could refer to all of the interest calculation code
as a single object—which you could then use over and over again just by using the
object name. Popular object-oriented programming languages include C++, Java,Visual
Basic, and Turbo Pascal. In object-oriented programming, an object is programming
code and data that can be treated as an individual unit or component. Data refers to
information contained within variables, constants, or other types of storage structures.
The functions associated with an object are referred to as methods.Variables that are
associated with an object are referred to as properties or attributes. Objects can range
from simple controls such as a button, to entire programs such as a database applica-
tion. Object-oriented programming allows programmers to use programming objects
that they have written themselves or that have been written by others. One of the most
powerful features of object-oriented programming is that it allows programmers to use
objects in their programs that may have been created in an entirely different
programming language.
For example, if you are creating an accounting program in Turbo Pascal, you can use an
object named Payroll that was created in C++. The Payroll object may contain one
method that calculates the amount of federal and state tax to deduct, another function
that calculates the FICA amount to deduct, and so on. Properties of the Payroll object
may include an employee’s number of tax withholding allowances, federal and state tax
percentages, and the cost of insurance premiums. You do not need to know how the
Payroll object was created in C++, nor do you need to re-create it in Turbo Pascal.You
only need to know how to access the methods and properties of the Payroll object from
the Turbo Pascal program. The object-oriented Accounting program is illustrated in
Figure 1-3. In the figure, the Accounting program is composed of three separate objects,
or components: an Accounts Receivable object, the Payroll object, and an Accounts
Payable object. The important thing to understand is that you do not need to rewrite
the Payroll, Accounts Payable, and Accounts Receivable objects for the Accounting pro-
gram; the Accounting program only needs to call their methods and provide the correct
data to their properties.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
1 Chapter A4535 25000 4/22/02 2:42 PM Page 7
Licensed to: iChapters User
Accounting Program
1
Accounts
Receivable
object
Accounts
Payble
object
Payroll
object
The diagram in Figure 1-3, along with other diagrams in this book, is created
in Unified Modeling Language, or UML, which is a symbolic language for
Note visually designing and documenting software systems. Each of the symbols in
Figure 1-3 is a UML representation of a component.
Objects are encapsulated, which means that all code and required data are contained
within the object itself. Encapsulation is also referred to as a black box, because of the
invisibility of the code inside an encapsulated object. When an object is well written,
you cannot see “inside” it—all internal workings are hidden. The code (methods and
statements) and data (variables and constants) contained in an encapsulated object are
accessed through an interface. An interface represents elements required for a source
program to communicate with an object. For example, interface elements required to
access a Payroll object might be a method named calcNetPay(), which calculates an
employee’s net pay, and properties containing the employee’s name and pay rate.
You can compare a programming object and its interface to a hand-held calculator.The
calculator represents an object, and you represent a program that wants to use the object.
You establish an interface with the calculator object by entering numbers (the data
required by the object) and then pressing calculation keys (which represent the meth-
ods of the object.) You do not need to know, nor can you see, the inner workings of the
calculator object. As a programmer, you are concerned only with what the methods and
properties are and what results to expect the calculator object to return. Figure 1-4 illus-
trates the idea of the calculator interface.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
1 Chapter A4535 25000 4/22/02 2:42 PM Page 8
Licensed to: iChapters User
Program
(You)
Object
(Calculator)
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
1 Chapter A4535 25000 4/22/02 2:42 PM Page 9
Licensed to: iChapters User
Consider the class upon which the Payroll object might be based. As mentioned, the
Payroll class (upon which the Payroll object is based) may include a method named
1
calcNetPay().The Payroll class may also include a calcFederalTaxes() method, a
calcStateTaxes() method, and a deductIRAContribution() method. Some of the proper-
ties of the Payroll class may include federalTaxRate, stateTaxRate, insurancePremium, and
iraContribution. Each time you create a new instance of the Payroll object, the object
inherits its own copies of these methods and objects. For example, a company that gen-
erates its payroll once a month would create 12 separate Payroll objects. Figure 1-5 illus-
trates how the January and February Payroll objects inherit all of the methods and
properties of the Payroll class.
Payroll Class
insurancePremium
federalTaxRate
stateTaxRate
iraContribution
calcNetPay()
calcFederalTaxes()
calcStateTaxes()
deductIRAContribution()
Although you will not return to object-oriented programming for several chapters, you
need to understand that the classes and objects you can create with C++ are the most
important and powerful part of the C++ programming language. In fact, the primary
goal of this book is to provide you with a firm foundation in the concepts of classes and
object-oriented programming. However, before you can learn about classes and object-
oriented programming in detail, you need to understand some of the more basic aspects
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
1 Chapter A4535 25000 4/22/02 2:42 PM Page 10
Licensed to: iChapters User
of C++, such as data types, functions, and decision-making statements. These concepts
will be examined in the next few chapters
C/C++ PROGRAMMING
The term C/C++ refers to two separate, but related, programming languages: C and C++.
At Bell Laboratories in the 1970s, Dennis Ritchie and Brian Kernighan designed the pro-
cedural C programming language based upon two earlier languages, BCPL and B. In 1985,
again at Bell Laboratories, Bjarne Stroustrup created C++ based on the C programming
language. C++ is an extension of C that adds object-oriented programming capabilities.
You create C and C++ programs in text files using a text-editing tool such as Notepad.
The original program structure you enter into a text file is referred to as source code.
Once you finish creating your program source code, you use a compiler to translate it
into the machine language of the computer on which the program will run. The com-
piled machine language version of a program is called object code. Once you compile
a program into object code, some systems require you to use a program called a linker,
which converts the object code into an executable file, typically with an extension of
.exe. Figure 1-6 uses a simple program that prints the text Hello World to a console appli-
cation window to show how source code is transformed into to object code and then
into an executable process.
You cannot read object code or the code in an .exe file.The only code format in human-
readable form is source code. In Visual C++, you compile and link a program in a single
step known as building.You will learn how to build a program later in this chapter.
Remember that each computer contains its own internal machine language. The
C/C++ compiler you use must be able to translate source code into the machine lan-
guage of the computer, or platform, on which your program will run. A platform is an
operating system and its hardware type. For example, Windows operating systems for
PCs, Mac OS 10 operating system for Macintosh, and Solaris for SPARC are different
platforms. Numerous vendors market C/C++ compilers for various platforms. Some
vendors offer complete development environments containing built-in code editors,
compilers, and linkers. Microsoft Visual C++ and Borland C++ Builder are examples of
C/C++ professional development environments that contain built-in code editors and
compilers, as well as many other development tools.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
1 Chapter A4535 25000 4/22/02 2:42 PM Page 11
Licensed to: iChapters User
C/C++ Programming 11
1
Source code
Object code
Executable file
(HelloWorld.exe)
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
1 Chapter A4535 25000 4/22/02 2:42 PM Page 12
Licensed to: iChapters User
the ANSI/ISO standard, the same C program can usually run on many different platforms.
However, C’s closeness to assembly language can also be a disadvantage. It can make C dif-
ficult to use and not ideally suited to certain types of applications, such as graphical appli-
cations and object-based programs that you want to use with other programming languages.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
1 Chapter A4535 25000 4/22/02 2:42 PM Page 13
Licensed to: iChapters User
C/C++ Programming 13
Visual C++ supports a number of extensions to the ANSI C/C++ run-time libraries.
Extensions are new or additional features that have been added to the original run-time
1
libraries.Visual C++ extensions may or may not be supported by other C/C++ compilers,
so you cannot be absolutely certain that any programs you write that use the extensions will
be able to run on other platforms. For example, Visual C++ extends the C++ language
by allowing you to include Microsoft Foundation Classes in your programs. Microsoft
Foundation Classes (MFCs), are libraries of classes that can be used as the building blocks
for creating Windows applications with Visual C++. It is very important to understand that
any Visual C++ programs you create that utilize MFCs will not conform to the ANSI
C/C++ standards, and therefore will not be able to run with other vendor’s C/C++ com-
pilers. If you need your C/C++ program to be portable to other platforms, you must use
only the standard ANSI C/C++ run-time libraries. Nevertheless, MFCs are an extremely
powerful feature of Visual C++ because they allow you to create true Windows applica-
tions. One of the primary uses of Visual C++ is in the creation of Windows applica-
tions, and many of the projects you create in this book will include MFCs and therefore
will not conform to ANSI C/C++.
You will learn how to use the various Visual C++ libraries throughout this book.
Note
The visual aspect of Visual C++ is used for designing the user interface of certain types of
programs, such as an MFC program.You can also use your mouse to draw some user inter-
face elements of your program, such as the controls in a dialog box, using various Visual C++
tools. Figure 1-7 shows an example of the visual portion of a calculator program that you
will work on in later chapters.You will draw the user interface elements shown in the fig-
ure using the controls displayed in the Toolbox window.
Figure 1-7 Visual portion of a calculator program that you will work on in later chapters
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
1 Chapter A4535 25000 4/22/02 2:42 PM Page 14
Licensed to: iChapters User
The Microsoft Visual Studio line of development tools includes a platform called the
.NET Framework that is designed for developing and running Internet applications,
primarily Web-based applications and services. As part of the .NET Framework,
Microsoft has introduced a new programming language, C# (pronounced C sharp). C#
is an object-oriented programming language based on C/C++ that creates Web-based
programs designed to run on the .NET Framework. This text does not discuss C#, but
focuses on traditional C++ programming. Traditional C++ programs, including Visual
C++ programs, are not designed to run on the .NET Framework. Rather, they are
designed to run on standard platforms such as Windows and UNIX operating systems.
You can find a supplemental chapter online at www.course.com that discusses how to use
Managed Extensions to write C++ programs that operate on the .NET Framework.
Managed Extensions are special sets of code that allow traditional C++ programs to
function on the .NET Framework.
To locate supplemental chapters and other support material for this book,
search on 0-619-01657-4 at www.course.com.
Tip
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
1 Chapter A4535 25000 4/22/02 2:42 PM Page 15
Licensed to: iChapters User
The code in the example uses a while statement, which is used to repeat a command
or series of commands based on the evaluation of certain criteria. The criterion in the
1
example is the value of a variable named count. The while statement is supposed to
execute until the count variable is less than or equal to 10.There is no code within the
while statement body however, that changes the count variable’s value.The count vari-
able will continue to have a value of 0 (zero) through each iteration of the loop. In this
program, as it is written, a line containing the text string The number is 0 will print on
the screen over and over again.
Do not worry about how the C++ code in the example is constructed. The
example is only meant to give you a better understanding of a logical error.
Note
Any error in a program that prevents it from compiling or causes it to function incor-
rectly, whether due to incorrect syntax or flaws in logic, is called a bug. Debugging
describes the act of tracing and resolving errors in a program. Legend has it that the term
debugging was first coined in the 1940s by Grace Murray Hopper, a mathematician who
was instrumental in developing the COBOL programming language. As the story goes,
a moth short-circuited a primitive computer that Hopper was using. Removing the
moth from the computer debugged the system and resolved the problem. Today, a bug
refers to any sort of problem in the design and operation of a program.
Do not confuse bugs with computer viruses. Bugs are errors within a program
that occur because of syntax errors, design flaws, and other types of errors.
Note Viruses are self-contained programs designed to “infect” a computer system
and cause mischievous or malicious damage. Actually, virus programs them-
selves can contain bugs if they contain syntax errors or do not perform (or
damage) as their creators envisioned.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
1 Chapter A4535 25000 4/22/02 2:42 PM Page 16
Licensed to: iChapters User
name you choose in the next exercise for your projects folder, this text refers to it as the
Visual C++ Projects folder throughout the course of this text.
To create a projects folder for the Visual C++ projects you create in this text:
1. If necessary, start Windows. Open Windows Explorer or My Computer.
2. Create a folder named Visual C++ Projects (or use another name if you like).
3. In your Visual C++ Projects folder, create a folder named Chapter.01 where
you will store the projects you create in this chapter.
4. Close Windows Explorer or My Computer.
Next, you will start creating a new project that you will use for the rest of this chapter
to demonstrate the basic Visual C++ development tools and windows. The project you
create in this chapter is for demonstration purposes only.
To create a new Visual C++ project:
1. Click the Start button on the taskbar. Point to the Programs folder (or the
All Programs button in Windows XP) on the Start menu. Point to Microsoft
Visual Studio .NET on the Programs menu, then click Microsoft Visual
Studio .NET. Figure 1-8 shows how Visual Studio appears when you start it
for the first time.
2. Click the New Project button in the Start Page window or point to New
on the File menu, then select Project. If necessary, when the New Project
dialog box appears, click the Visual C++ Projects folder in the Project
Types list. Also if necessary, click the More button to display more options in
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
1 Chapter A4535 25000 4/22/02 2:42 PM Page 17
Licensed to: iChapters User
the New Project dialog box. The caption on the More button changes to Less
if all of the options in the dialog box are currently displayed. The Visual C++
1
Projects folder of the New Project dialog box is shown in Figure 1–9.
Figure 1-9 The Visual C++ Projects folder of the New Project dialog box
When you first see the New Projects dialog box, you might be intimidated by
the many available options. Keep in mind that Visual Studio is a high-level
Note programming environment and that many of the options in the New dialog
box are used primarily by professional programmers. By the end of this text,
you will understand how to work with many of the Visual C++ options in the
New Project dialog box.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
1 Chapter A4535 25000 4/22/02 2:42 PM Page 18
Licensed to: iChapters User
7. Click the OK button. The Win32 Application Wizard appears, describing the
type of application you are creating. Click the Application Settings tab. In
this tab, you can select the specific application type and options that you want
to create. Figure 1-10 shows the Application Settings tab of the Win32
Application Wizard dialog box.
Figure 1-10 Application settings tab of the Win32 Application Wizard dialog box
8. The default Windows application setting type is fine for our purposes, so
click the Finish button.Visual C++ creates a new project called HelloWorld
in the HelloWorld folder in the Chapter.01 folder in your Visual C++
Projects folder. The Integrated Development Environment appears.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
1 Chapter A4535 25000 4/22/02 2:42 PM Page 19
Licensed to: iChapters User
control menu
1
title bar
control buttons
menu buttons
toolbar
Start Page
Solution Explorer
status bar
Note
You can customize various aspects of Visual Studio by selecting Options from
the Tools menu.
Tip
Projects can be part of one solution or part of more than one solution. They can be
opened individually within a new solution or as part of an existing solution.Any changes
to the project itself are reflected in all solutions in which the project is contained. Note
that the solutions you create in this book will all consist of a single project. For this rea-
son, whenever you create a new project, be sure to clear the Create directory for
Solution check box.
For the rest of this chapter, you will use the HelloWorld project to learn how to work
with several of the basic development tools and windows that are available to a Visual
C++ application.You will also learn about the various techniques for managing the files
and how to obtain help in Visual Studio .NET. Keep in mind that this chapter intro-
duces only the basic tools and windows that you will need throughout this text.
However, Visual C++ includes many other tools and windows than are introduced in
this chapter. Some tools and windows are only available to certain types of applications.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
1 Chapter A4535 25000 4/22/02 2:42 PM Page 20
Licensed to: iChapters User
Others are somewhat advanced and require a solid understanding of the basics of C++
programming.You will learn about many of the various C++ tools and windows as nec-
essary during the course of your study.
You must have a newsgroup reader configured on your system before you
can access any newsgroups through the Online Community link.
Note
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
1 Chapter A4535 25000 4/22/02 2:42 PM Page 21
Licensed to: iChapters User
Next, you will set your IDE user preferences in the My Profile section of the Start Page. 1
To set your IDE user preferences in the My Profile section of the Start Page:
1. Click the My Profile link on the Start Page.
2. If neccesary, select Visual C++ Developer in the Profile combo box.
Selecting a profile in the Profile combo box automatically sets the options in
the Keyboard Scheme, Window Layout, and Help Filter combo boxes. The
Keyboard Scheme sets the shortcut keys that you can use within Visual
Studio. The Window Layout combo box sets the arrangement of the various
windows within Visual Studio. The Help Filter combo box filters the infor-
mation displayed in the MSDN Library and on the Startup Page. After you
select Visual C++ Developer in the Profile combo box, the Keyboard
Scheme and Window Layout combo boxes should change to Visual C++ 6,
and the Help Filter combo box should change to Visual C++.
3. The Show Help section contains two choices: Internal Help and External Help.
The Internal Help choice displays MSDN Library help information within the
IDE. External Help displays MSDN Library help in a separate window.
Displaying help internally can make the IDE crowded and difficult to work with,
so select External Help (if necessary). A dialog box appears notifying you that
changes will not take effect until Visual Studio is restarted. Click the OK button
to continue.
4. The last option in the My Profile section is the At Startup combo box, which
determines what will appear when you first open Visual Studio. Expand the
combo box to see the available options, and if necessary, select Show Start
Page. Figure 1-12 shows how the My Profile section your IDE should appear.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
1 Chapter A4535 25000 4/22/02 2:42 PM Page 22
Licensed to: iChapters User
Changing how Help appears does not take effect until you close and restart
?
Help
Visual Studio. If you needed to change your Show Help option to External
Help, be sure to close and then reopen Visual Studio before continuing. Once
you reopen Visual Studio, open the HelloWorld project by clicking its name
on the Get Started screen on the Start Page.
solution
project
folder
file
2. The first item in the Solution Explorer window is the Solution icon. Beneath
the Solution icon is a Project icon for the HelloWorld project. The
HelloWorld project contains several folders containing the various files that
make up the project. The Plus box and Minus box located to the left of each
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
1 Chapter A4535 25000 4/22/02 2:42 PM Page 23
Licensed to: iChapters User
folder icon are used for expanding and collapsing folders. The Plus box indi-
cates that an item contains other items that are not currently visible. The
1
Minus box indicates that all items beneath the associated item are currently
visible. By default, all of a project’s folders are expanded, so you will not see
any Plus icons. Try clicking the Minus box next to the Source Files folder. All
the files in the Source Files folder are hidden, and the Minus box changes
to a Plus box.
The Plus box and Minus box are also used in Windows Explorer for expand-
ing and collapsing drives and folders.
Note
3. Click the Plus box again to redisplay all the files within the Source Files
folder. For now, do not worry about what these files are used for; you will
learn about the various files types used in Visual C++ throughout the course
of this text.
You can also display the Solution Explorer window by clicking the Solution
Explorer button on the Standard toolbar or by pressing Ctrl+Alt+L.
Tip
Notice the three tabs that are visible at the bottom of the Solution Explorer window:
Solution Explorer, Class View, and Resource View. Class View displays project files
according to their classes, which are arranged as folders in the project directory.
Resource View displays the files that are used specifically for building a Windows appli-
cation.You will work mostly with Solution Explorer for the next few chapters.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Random documents with unrelated
content Scribd suggests to you:
croyait pas plus durable. L'opinion lui savait moins gré d'avoir vaincu
les insurrections, qu'elle ne lui imputait à grief de les avoir
encouragées et en quelque sorte provoquées par sa faiblesse. Et
surtout, nul ne le croyait en état de tirer de la victoire tout ce qu'elle
contenait. «Le Roi a beaucoup gagné, écrivait un des chefs du parti
conservateur, non-seulement dans les rues, mais dans les salons.
C'est le propos courant du faubourg Saint-Germain que, le 6 juin, il a
pris sa couronne..... Mais le cœur me saigne de tout ce que pourrait
rapporter et ne rapportera probablement pas ce capital. Je crains
fort que nous ne le dépensions, au lieu de le faire fructifier. C'est le
moment ou jamais de prendre une attitude et de commencer une
conduite de gouvernement. Le cri en arrive de tous côtés. Beaucoup
de gens le répètent; tous viennent, s'agitent, mais sans effet. Rien
n'est possible que par un vrai cabinet. Celui-ci n'est rien, de plus en
plus rien; le succès ne lui est bon qu'à faire ressortir sa nullité[184].»
CHAPITRE IX.
LA FORMATION ET LES DÉBUTS DU MINISTÈRE DU 11
OCTOBRE
I. Louis-Philippe, obligé à regret de modifier son ministère, s'adresse à M. Dupin.
Refus de ce dernier. Ses motifs. Le maréchal Soult chargé de former un
cabinet de coalition conservatrice. Difficultés venant des préventions soulevées
contre M. Guizot. Ouvertures faites au duc de Broglie.—II. Antécédents du duc
de Broglie, peu populaire, mais très-respecté. Son éloignement pour le
pouvoir. Il ne veut pas entrer au ministère sans M. Guizot.—III. On accepte M.
Guizot, en le plaçant au ministère de l'Instruction publique. Composition et
programme du cabinet.—IV. Nécessité pour le ministère d'en imposer à
l'opinion. Occasion fournie par la question belge. Convention du 22 octobre
avec l'Angleterre. Les troupes françaises en marche contre Anvers.—V.
Mesures prises par M. Thiers pour se saisir de la duchesse de Berry. Trahison
de Deutz. Que faire de la prisonnière? On écarte l'idée d'un procès. La
princesse transférée à Blaye.—VI. Ouverture de la session. Discussion de
l'Adresse. Succès du ministère.—VII. Siége et prise d'Anvers. Résultats
heureux de cette expédition pour la Belgique et pour la France.—VIII. Débats
à la Chambre, sur la duchesse de Berry. Le bruit se répand que celle-ci est
enceinte. Agitation des esprits et conduite du gouvernement. Après son
accouchement et la déclaration de son mariage secret, la princesse est mise
en liberté. Sentiments du Roi en cette affaire. Faute commise.—IX. Les
royalistes obligés de renoncer à la politique des coups de main. Berryer. Son
origine. Son attitude après 1830. Il cherche à être l'orateur de toute
l'opposition. Son succès. Avantages qui en résultent pour le parti royaliste.
Berryer attaqué cependant par une fraction de ce parti.—X. Chateaubriand se
tient à l'écart, découragé, bien que non adouci. Son état d'esprit. Sa triste
vieillesse.—XI. Fécondité législative des sessions de 1832 et 1833. Calme et
prospérité du pays. Après tant de secousses, était-on donc enfin arrivé à
l'heure du repos?
Ces chefs, chacun les nommait; on les avait vus à l'œuvre sous
Périer: c'étaient, avec M. Dupin, MM. Guizot et Thiers. Aucune
difficulté pour l'entrée de ce dernier. Sa fortune était encore trop
récente et son origine trop humble, pour porter ombrage soit au
Parlement, soit au Roi. Il était demeuré partisan très-résolu de la
résistance, et M. Guizot pouvait écrire au duc de Broglie: «J'ai vu
Thiers, qui est revenu dans d'excellentes dispositions, nullement
troublé des charivaris de Marseille, et fort éclairé par ses
conversations avec tous les étrangers qu'il a vus à Rome[201].» Les
choses allaient moins facilement pour M. Guizot. Son impopularité,
que nous avons déjà signalée sous le ministère du 13 mars, semblait
s'accroître à mesure que sa rentrée au pouvoir était plus indiquée et
plus urgente[202]. Son patriotisme était cependant trop alarmé, et
aussi son ambition trop en éveil, pour qu'il se laissât facilement
exclure du gouvernement; voyant le péril public, estimant son heure
venue, il avait soif d'agir. Mais Louis-Philippe hésitait à braver les
préventions que ce nom soulevait. Peut-être, à cette époque, les
partageait-il dans une certaine mesure. Que faire alors? Car il n'avait
pas l'illusion que M. Thiers seul suffît, et qu'il y eût moyen de faire
un ministère de résistance en excluant les doctrinaires qui étaient,
après tout, les plus capables et les plus fermes des conservateurs.
Ne pourrait-on donc pas avoir ceux-ci, tout en évitant M. Guizot? De
là vint l'idée d'offrir un portefeuille à un autre éminent doctrinaire,
au duc de Broglie, qui, retiré jusqu'alors dans l'enceinte un peu
silencieuse de la Chambre des pairs, avait attiré sur lui moins
d'inimitiés. Nous l'avions déjà entrevu, au second rang et dans une
ombre volontaire, parmi les membres du ministère de l'avénement.
Appelé maintenant à un rôle plus considérable, il mérite de fixer
davantage notre attention.
II
III
Il fallait en finir. L'opinion s'impatientait de ces retards et de ces
hésitations. M. Dupin, interrogé de nouveau, repoussa toute
ouverture avec aigreur, aussi mécontent qu'on vînt le relancer que
jaloux des offres faites aux autres. Dès lors, il ne restait que les
doctrinaires. Les plus fidèles partisans de la monarchie se plaignaient
de l'exclusion qu'on faisait peser sur cette fraction des
conservateurs. «La coalition de tous les talents», disait le Journal
des Débats, est nécessaire pour «combler le vide» produit par la
mort de Périer, et il ajoutait ces graves avertissements: «C'est à
grand'peine que, depuis juillet 1830, les vrais amis de la révolution
ont résisté au torrent qui menaçait de tout engloutir. Le danger a été
plutôt évité que conjuré, le mal, suspendu plutôt que guéri; la
désorganisation est encore à nos portes... Ayez peur de l'opposition:
ménagez-la; désavouez un seul de vos antécédents; séparez-vous
d'un seul de vos amis: vous lui rendez des chances[209].» M. Thiers
lui-même ne croyait pas qu'on pût rien faire sans les doctrinaires: «Il
fallait des forces, écrivait-il, et où les prendre, quand Dupin
refusait?... En conscience, où trouver des hommes plus capables,
plus honorables, plus dignes de la liberté, que MM. de Broglie,
Guizot et Humann? Ne faut-il pas un infâme génie de calomnie pour
trouver à dire contre des hommes pareils[210]?» Et cependant Louis-
Philippe redoutait toujours de prendre un ministre trop impopulaire.
Dans cet embarras, une transaction fut proposée, à laquelle le Roi se
rallia: elle consistait à offrir à M. Guizot, non le ministère de
l'Intérieur qu'il avait déjà occupé dans le cabinet du 11 août, mais le
ministère de l'Instruction publique qui était moins en vue, moins
politique, et pour lequel l'ancien professeur de la Sorbonne était,
comme il le disait, «une spécialité». M. Guizot eut l'esprit de ne pas
élever d'objection d'amour-propre. D'une part, il savait avoir
beaucoup à faire dans ce département; d'autre part, il comptait sur
son talent de parole pour jouer, quand même, un grand rôle dans le
Parlement et, par suite, tenir une grande place dans le cabinet.
IV
À voir l'accueil que lui firent les journaux, on n'eût pas promis
longue vie au nouveau cabinet. Sauf le Journal des Débats, tous se
montraient violemment hostiles, depuis le National et la Tribune
jusqu'au Constitutionnel, en passant par le Temps, le Courrier
français, le Journal du Commerce. «Non, mille fois non, s'écriait le
Constitutionnel, ce n'est pas l'opposition seule, c'est la France
entière qui pousse ce cri: Arrière! arrière! hommes de la
Doctrine[212]!»Le ministère était comparé à celui de M. de Polignac
et devait conduire à une semblable catastrophe; on racontait que
Louis-Philippe préparait déjà sa fuite et faisait passer des fonds à
l'étranger. Grisés par leur propre tapage, les opposants finissaient
par se croire sûrs d'une prochaine victoire. Par contre, les amis du
cabinet, assourdis, quelque peu intimidés, se demandaient avec
inquiétude ce qui allait se passer à la rentrée des Chambres[213]. Ne
savaient-ils pas combien était encore peu consistante la majorité de
combat que Périer avait rassemblée et entraînée, pour ainsi dire, à la
force du poignet? La situation pouvait donc devenir périlleuse. Les
ministres comprirent qu'il leur fallait, dans les quatre ou cinq
semaines qui les séparaient du 19 novembre, date indiquée pour
l'ouverture de la session, accomplir au dedans ou au dehors quelque
acte qui en imposât à l'opinion.
VI
VII
VIII
Que valait donc au fond cette «raison d'État» que les ministres
invoquaient et à laquelle le Roi s'était cru contraint de céder? Sans
doute, on avait ainsi tué politiquement une princesse entreprenante,
la seule qui, dans sa famille, pût rêver de guerre civile; on avait
porté un coup et surtout infligé une cruelle mortification à une
dynastie rivale et à un parti ennemi. Mais n'était-ce pas acheté bien
cher? Était-il habile de blesser à ce point les royalistes, de provoquer
chez eux d'aussi implacables ressentiments, et d'affronter le genre
de reproches auxquels un tel acte devait donner lieu? À l'heure où le
respect de la royauté se trouvait déjà si ébranlé, était-il prudent d'y
porter une nouvelle atteinte, en livrant à la malignité, à l'insolence et
au mépris publics les faiblesses d'une princesse royale? S'imaginait-
on que ce qui était retranché ainsi à la dignité de la branche aînée
était ajouté à celle de la branche cadette? N'était-ce pas plutôt une
perte pour la cause monarchique elle-même, sous toutes ses
formes; une diminution du trésor commun de prestige et d'honneur,
également nécessaire à toutes les dynasties? N'était-ce pas en un
mot, de la part des hommes de 1830, une faute analogue à celle
que commettaient les légitimistes, quand ils traînaient dans la boue
Louis-Philippe, sans comprendre que toute royauté était par là
rabaissée? Parmi les amis les plus dévoués du gouvernement de
Juillet, quelques-uns avaient, dès cette époque, le sentiment de
cette faute: «Le gouvernement, dit le général de Ségur dans ses
Mémoires, abusa déplorablement de sa victoire; je veux parler de
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade
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.
ebookname.com