This is not the document you are looking for? Use the search form below to find more!

Report home > Computer / Internet

Teach Yourself Borland C++ in 14 Days

2.00 (6 votes)
Document Description
In Week 1 you will get a start on learning how to write Windows programs in C++. The C++ language is not an easy language to learn. It is, however, the standard programming language in many corporations and governments around the world. Learning C++ might not be the easiest task you could attempt to tackle, but it should be very rewarding, both intellectually, and, eventually, monetarily.
File Details
Submitter
  • Username: dutcher
  • Name: Lisa W. Dutcher
  • Documents: 30

We are unable to create an online viewer for this document. Please download the document instead.

Teach Yourself Borland C++ in 14 Days screenshot

Add New Comment




Related Documents

How Can I Jump Higher In 14 Days

by: atsushi, 9 pages

How Can I Jump Higher in 14 Days? FixAndCureOnline.com/jumphigher If you an avid internet user then you may know that jumping higher ...

Acne No More vs Acne Free in 3 Days Review

by: Laura, 3 pages

Guide to finding the right acne treatment solution. Find out more about Acne no more and Acne free in 3 days online

PERL in 21 Days

by: corsican, 1124 pages

Teach Yourself PERL 5 in 21 Days by David Till

Master Cleanse Secrets - How Beyonce Knowles Lost 22 Lbs . in 14 Days

by: nepal39bangle, 2 pages

Other Learn Cleanse users have documented better pores and skin well being, more energy, elevated ha...

Discover How To Teach Yourself Spanish And Finally Have A Spanish Conversation2

by: james343may, 2 pages

You can also find some English commercials that are on the Spanish channel so you can figu re out what the words Get help from your Spanish speaking friends Make it a daily habit to try and ...

How To Get A Job in 30 days or less book

by: hot0scale, 2 pages

Your goals for the week are also laid out, and you are reminded to celebrate each and every step of ...

Teach Yourself Basecamp in 10 Minutes Book Excerpt

by: secondo, 23 pages

Patrice-Anne Rutledge Sams Teach Yourself ® Basecamp in 10 Minutes 800 East 96th Street, Indianapolis, Indiana ...

The P90X Workout - How I Changed From a Couch Potato to a Ripped Dude in 90 Days With the P90X:-

by: shaunyork228, 1 pages

In case you haven't been following any of my other articles on this whole fitness gig, let me recap briefly. After my girlfriend came right out with it and called me an out-of-shape slob to my face ...

Autohemotherapy cures Goats in 15 days

by: Autohemotherapy, 7 pages

Goats treated with Autohemotherapy (cured in 15 days) STUDY of the UFRPE - Veterinary Medicine Rural Federal University of Pernambuco, Brazil. OBJECTIVE: The aim of this study is to ...

Can You Teach Yourself Violin?

by: jian, 5 pages

Can You Teach Yourself Violin?

Content Preview
At A Glance
1
WEEK
1
1
2
3
4
At a Glance
5
In Week 1 you will get a start on learning how to write Windows
programs in C++. The C++ language is not an easy language to learn. It
is, however, the standard programming language in many corporations
and governments around the world. Learning C++ might not be the
easiest task you could attempt to tackle, but it should be very rewarding,
both intellectually, and, eventually, monetarily.
6
Your first four days will be spent learning about the basics of the C++
language. As you work through the first four chapters, you will write
simple test programs, each of which will help you solidify a particular
feature of the C++ language. I warn you, though, that these programs
will probably not be the type of program that you purchased C++Builder
7
to write. The test programs for the first four days will be console
applications. These programs work just like DOS programs. They won’t
Untitled-16
1
1/19/99, 1:01 PM
P2/V5/Swg2 TY C++ Builder in 14 Days 31051-1 Lenser 1.14.97 At a GlanceWK1 LP#3

2
Week 1
have any flash or glitter. You probably won’t be terribly impressed. These programs will,
however, help to teach you the basics of C++, and that is what the first four days of this book
are about.
Starting on Day 5 you’ll begin to learn about some of the things that make the visual
programming aspect of C++Builder the great tool that it is. We will talk about frameworks
and what a framework means to you as a Windows programmer. On Day 5 you will build
a simple test program using C++Builder’s visual programming tools. After that we will spend
a couple days going over the C++Builder IDE so that you can become familiar with how the
entire C++Builder IDE works together to make your programming tasks easier. This is where
things start to get more interesting. You will get an opportunity to write some working
Windows programs in the last part of this first week. So, with that in mind, let’s get to it.
Untitled-16
2
1/19/99, 1:01 PM
P2/V5/Swg2 TY C++ Builder in 14 Days 31051-1 Lenser 1.14.97 At a GlanceWK1 LP#3

Getting Your Feet Wet
3
Week 1 1
Day 1
Getting Your Feet Wet
by Kent Reisdorph
Congratulations—you’ve chosen one of today’s hottest new programming
tools! Before you can jump into using all of what C++Builder has to offer,
though, you’ll need to learn a little about C++ first. In this chapter you will find
s A quick tour of C++Builder
s Information about how to write a Win32 console-mode application
s An introduction to the C++ language
s Facts about C++ variables and data types
s Information about functions in C++ (including the main() function)
s A discussion of arrays
Untitled-10
3
1/19/99, 12:48 PM
P2/V5/swg2 TY C++ Builder in 14 Days 31051-1Lenser 1.15.97 CH01 LP#4

4
Day 1
What Is C++Builder?
By now you know that C++Builder is Borland’s hot new rapid application development
(RAD) product for writing C++ applications. With C++Builder you can write C++ Windows
programs more quickly and more easily than was ever possible before. You can create Win32
console applications or Win32 GUI (graphical user interface) programs. When creating
Win32 GUI applications with C++Builder, you have all the power of C++ wrapped up in a
RAD environment. What this means is that you can create the user interface to a program
(the user interface means the menus, dialog boxes, main window, and so on) using drag-and-
drop techniques for true rapid application development. You can also drop OCX controls
on forms to create specialized programs such as Web browsers in a matter of minutes.
C++Builder gives you all of this, but you don’t sacrifice program execution speed because you
still have the power that the C++ language offers you.
I can hear you saying, “This is going to be so cool!” And guess what? You’re right! But before
you go slobbering all over yourself with anticipation, I also need to point out that the C++
language is not an easy one to master. I don’t want you to think that you can buy a program
like C++Builder and be a master Windows programmer overnight. It takes a great deal of
work to be a good Windows programmer. C++Builder does a great job of hiding some of the
low-level details that make up the guts of a Windows program, but it cannot write programs
for you. In the end, you must still be a programmer, and that means you have to learn
programming. That can be a long, uphill journey some days. The good news is that
C++Builder can make your trek fairly painless and even fun. Yes, you can work and have fun
doing it!
So roll up your sleeves and get your hiking shoes on. C++Builder is cool, so have fun.
A Quick Look at the C++Builder IDE
This section contains a quick look at the C++Builder IDE. We’ll give the IDE a once-over
here, and we’ll examine it in more detail on Day 6, “The C++Builder IDE Explored: Projects
and Forms.” Because you are tackling Windows programming, I’ll assume you are advanced
enough to have figured out how to start C++Builder. When you first start the program, you
are presented with both a blank form and the IDE, as shown in Figure 1.1.
The C++Builder IDE (which stands for integrated development environment) is divided into
three parts. The top window might be considered the main window. It contains the speedbar
on the left and the Component Palette on the right. The speedbar gives you one-click access
to tasks like opening, saving, and compiling projects. The Component Palette contains a
wide array of components that you can drop onto your forms. (Components are things like
text labels, edit controls, list boxes, buttons, and the like.) For convenience, the components
Untitled-10
4
1/19/99, 12:48 PM
P2/V5/swg2 TY C++ Builder in 14 Days 31051-1 Lenser 1.15.97 CH01 LP#4

Getting Your Feet Wet
5
are divided into groups. Did you notice the tabs along the top of the Component Palette? Go
ahead and click on the tabs to explore the different components available to you. To place
a component on your form, you simply click the component’s button in the Component
Palette and then click on your form where you want the component to appear. Don’t worry
1
about the fact that you don’t yet know how to use components. We’ll get to that in due time.
When you are done exploring, click on the tab labeled Standard, because you’ll need it in a
moment.
Figure 1.1.
The C++Builder
IDE and the initial
blank form.

A component is a self-contained piece of binary software that performs some specific
NEW TERM
predefined task, such as a text label, an edit control, or a list box.
Below the speedbar and Component Palette and glued to the left side of the screen is the
Object Inspector. It is through the Object Inspector that you modify a component’s
properties and events. You will use the Object Inspector constantly as you work with
C++Builder. The Object Inspector has one or two tabs, depending on the component
currently selected. It always has a Properties tab. A component’s properties control how the
component operates. For example, changing the Color property of a component will change
the background color of that component. The list of available properties varies from
component to component, although components usually have several common elements
(Width and Height properties, for instance).
Untitled-10
5
1/19/99, 12:48 PM
P2/V5/swg2 TY C++ Builder in 14 Days 31051-1Lenser 1.15.97 CH01 LP#4

6
Day 1
NEW TERM
A property determines the operation of a component.
Usually the Object Inspector has an Events tab in addition to the Properties tab. Events occur
as the user interacts with a component. For example, when a component is clicked, an event
fires and tells Windows that the component was clicked. You can write code that responds
to those events, performing specific actions when an event occurs. As with properties, the
events that you can respond to vary from component to component.
An event is a method that is invoked in a component as a result of that component’s
NEW TERM
interaction with the user.
To the right of the Object Inspector is the C++Builder workspace. The workspace initially
displays the Form Editor. It should come as no surprise that the Form Editor allows you to
create forms. In C++Builder a form represents a window in your program. The form might
be the program’s main window, a dialog box, or any other type of window. You use the Form
Editor to place, move, and size components as part of the form creation process. Hiding
behind the Form Editor is the Code Editor. The Code Editor is where you type code when
writing your programs. The Object Inspector, Form Editor, Code Editor, and Component
Palette work interactively as you build applications.
Now that you’ve had a look at what makes up the C++Builder IDE, let’s actually do
something.
Hello World
It’s tradition. Almost all programming books start you off by having you create a program
that displays Hello World on the screen. I’m tempted to do something else, but tradition is
a force to be reckoned with, so Hello World it is. You’ve got some work ahead of you in the
next few chapters, so I thought I’d give you a taste of C++Builder’s goodies before putting
you to work on learning the seemingly less-glamorous basics of C++. You’ll have a little fun
before you have to go on the chain gang. C++Builder (and its cousin, Delphi) possibly allow
you the quickest route to Hello World of any Windows programming environment to date.
Right now you should have C++Builder running, and you should be looking at a blank form.
By default, the form is named Form1. (The form name is significant in C++Builder, but I’ll
address that a little later.) To the left of the form, the Object Inspector shows the properties
for the form. Click on the title bar of the Object Inspector. The Caption property is
highlighted, and the cursor is sitting there waiting for you to do something. (If the Caption
property is not in view, you might have to scroll the Object Inspector window to locate it.
Properties are listed in alphabetical order.) Type Hello World! to change the form’s caption.
Untitled-10
6
1/19/99, 12:48 PM
P2/V5/swg2 TY C++ Builder in 14 Days 31051-1 Lenser 1.15.97 CH01 LP#4

Getting Your Feet Wet
7
NOTE
As you modify properties, C++Builder will immediately display the
results of the property change when appropriate. As you type the new
caption, notice that the window caption of the form is changing to
1
reflect the text you are typing.
Now click the Run button on the speedbar (the one with the green arrow). (You could also
press F9 or choose Run | Run from the main menu.) C++Builder begins to build the
program. The compiler status dialog box, shown in Figure 1.2, is displayed, and you can
watch as C++Builder whips through the files necessary to build your program. After a brief
wait, the compiler status box disappears, the form is displayed, and the caption shows Hello
World!. In this case, the running program looks almost identical to the blank form. You may
scarcely have noticed when the program was displayed because it is displayed in the exact
location of the form in the Form Editor. (There is a difference, though, because the Form
Editor displays an alignment grid and the running program does not.) Congratulations—
you’ve just written your first C++ Windows program with C++Builder. Wow, that was easy!
“But what is it?” you ask. It’s not a lot, I agree, but it is a true Windows program. It can be
moved by dragging the title bar, it can be sized, it can be minimized, it can be maximized,
and it can be closed by clicking the Close button.
Figure 1.2.
The compiler status
dialog box.

Okay, so maybe displaying Hello World! just in the caption was cheating a little. Let’s spruce
it up a bit. If you still have the Hello World program running, close it by clicking the Close
button in the upper-right corner of the window. The Form Editor is displayed again, and you
are ready to modify the form (and, as a result, the program).
To make the program more viable, we’re going to add text to the center of the window itself.
To do this, we’ll add a text label to the form. First, click on the Standard tab of the
Component Palette. The third component button on the palette has an A on it. If you put
your mouse cursor over that button, the tool tip will display Label. Click the label button and
then click anywhere on the form. A label component is placed on the form. Now turn your
attention to the Object Inspector. It now displays the properties for Label1 (remember that
before it was showing the properties for Form1). Again the Caption property is highlighted.
Untitled-10
7
1/19/99, 12:48 PM
P2/V5/swg2 TY C++ Builder in 14 Days 31051-1Lenser 1.15.97 CH01 LP#4

8
Day 1
Click on the title bar of the Object Inspector or on the Caption property and type Hello
World!. Now the label on the form shows Hello World!. As long as we’re at it, let’s change
the size of the label’s text as well. Double-click on the Font property. The property will expand
to show the additional font attributes below it. Locate the Size property under Font and
change the font size to 24 (it is currently set to 8). As soon as you press the Enter key or click
on the form, the label instantly changes to the new size.
Because the label is probably not centered on the form, you may want to move it. To move
a component, simply click on it and drag it to the position you want it to occupy. Once you
have the label where you want it, you’re ready to recompile and run the program. Click the
Run button again. C++Builder compiles the program again and, after a moment (shorter this
time), the program runs. Now you see Hello World! displayed in the center of the form as
well as in the caption. Figure 1.3 shows the Hello World program running.
Figure 1.3.
The Hello World
program running.

With this little taste of C++Builder, you can see that writing C++ Windows programs with
C++Builder is going to be a great deal more interesting than it was in the good ol’ days. To
prepare for what you are going to do next, you need to close the current project in the
C++Builder IDE. Choose File | Close All from the main menu. Click No when prompted
to save changes to Project1, or save the project as HelloWorld if you are fond of your new
creation.
Hello World, Part II—A Win32 Console
Application

In the next couple chapters you are going to learn the basics of the C++ language. Along the
way you will write some simple test programs. These test programs will work best as console
applications. For all intents and purposes, these programs look like DOS programs when they
run. There are some major differences between a Win32 console app and a DOS program,
Untitled-10
8
1/19/99, 12:48 PM
P2/V5/swg2 TY C++ Builder in 14 Days 31051-1 Lenser 1.15.97 CH01 LP#4

Getting Your Feet Wet
9
but you need not be concerned about that right now. So, without further ado, let’s create
Hello World as a Win32 console program with C++Builder.
A Win32 console application is a 32-bit program that runs in a DOS box under
NEW TERM
1
Windows 95 or Windows NT.
From the main menu, choose File | New. C++Builder displays the Object Repository.
Curiously enough, the Object Repository’s title bar says New Items, but don’t be thrown by
that. The Object Repository contains predefined projects, forms, dialog boxes, and other
objects you can add to your applications or use to begin a new project. I will discuss the Object
Repository in detail on Day 9, “Creating Applications in C++Builder.” For now, click on the
New tab in the Object Repository and double-click Console App to start a new console
application project. C++Builder creates the project and displays the Code Editor so that you
can enter code for the program. Figure 1.4 shows the Code Editor as it appears when starting
a new console-mode application.
Figure 1.4.
The C++Builder
Code Editor window.

You will notice a couple of differences between the C++Builder IDE now and how it looked
earlier when we created a GUI application. First, there is no Form Editor. That’s because a
console application can’t display forms (well, that’s not completely true, but it’s accurate
enough for this discussion). Also notice that the Object Inspector is blank. You can only place
components on a form, so the Object Inspector is useless in a console application.
When writing console applications, you can close the Object Inspector
TIP
to make more room for the Code Editor window. Close the Object
Inspector by clicking the Close button on the Object Inspector’s title
bar. To bring back the Object Inspector, press F11 or choose
View | Object Inspector from the main menu.
Untitled-10
9
1/19/99, 12:48 PM
P2/V5/swg2 TY C++ Builder in 14 Days 31051-1Lenser 1.15.97 CH01 LP#4

10
Day 1
When you examine the Code Editor, you should see the following text displayed in the editor
window:
//--------------------------------
#include <condefs.h>
#include <stdio.h>
#include <stdlib.h>
#pragma hdrstop
//--------------------------------
int main(int argc, char **argv)
{
return 0;
}
//--------------------------------
This is a do-nothing C++ program, but a valid C++ program nonetheless. We’ll
ANALYSIS modify the code in just a moment to make this program actually do something, but
first I want you to notice the lines that begin with //. These are comment lines that, in this
program, serve no purpose other than to divide the program’s code visually. (You will
normally use comment lines to document your code.) C++Builder adds these comment lines
automatically when a new console application is first created. (In future code listings I will
eliminate the comment lines to save space.) Notice also that the single statement in this code
ends in a semicolon. (I know it doesn’t make sense right now, but there is only one actual
executable statement in this program.) The semicolon is used at the end of each statement
in a C++ program.
Very early in the process of learning the C and C++ languages, the budding programmer
must learn the difference between an expression and a statement. The “official” definition
of a statement is “an expression that is followed by a semicolon.” The semicolon closes an
expression and makes it a kind of single-line block of code. I’ll get into the code block soon,
but for now you should realize that an expression is a unit of code that evaluates to some
quantity. A statement is an expression that is closed. For example, consider the following
statement:
c = a + b;
In this example, the portion to the right of the equal sign, a + b, is an expression. The entire
line is a statement. I know this may be a bit confusing at the moment, but it should become
clearer as we go along. I’ll try to be very careful when I use these two terms. For now, though,
just remember that a statement is followed by a semicolon and is a closed expression.
Also notice the opening and closing braces in the program. In C++, a block of code begins
with the opening brace ({) and ends with the closing brace (}). The braces are used to delineate
the beginning and end of code blocks associated with loops, functions, if statements, and in
other cases as well. In this program there is only one set of braces because it is a simple
program.
Untitled-10
10
1/19/99, 12:48 PM
P2/V5/swg2 TY C++ Builder in 14 Days 31051-1 Lenser 1.15.97 CH01 LP#4

Document Outline
  • Overview
  • Contents
  • Introduction
  • Week 1 At a Glance
    • Day 1 Getting Your Feet Wet
    • Day 2 Wading In Deeper
    • Day 3 Up to your Neck in C++
    • Day 4 Totally Immersed: C++ Classes and Object-Oriented Programming
    • Day 5 C++ Class Frameworks and the Visual Component Model
    • Day 6 The C++Builder IDE Explored: Projects and Forms
    • Day 7 Working with the Form Designer and the Menu Designer
  • Week 1 In Review
  • Week 2 At a Glance
    • Day 8 VCL Components
    • Day 9 Creating Applications in C++Builder
    • Day 10 More on Projects
    • Day 11 Using the Debugger
    • Day 12 C++Builder Database Architecture
    • Day 13 Building Internet Applications
    • Day 14 C++Builder Extensions to C++
  • Week 2 In Review
  • Appendix A Answers to Quiz Questions
  • Index
  • Add to Your Sams Library
  • Quick Reference
  • Technical Support:
  • Internet

Download
Teach Yourself Borland C++ in 14 Days

 

 

Your download will begin in a moment.
If it doesn't, click here to try again.

Share Teach Yourself Borland C++ in 14 Days to:

Insert your wordpress URL:

example:

http://myblog.wordpress.com/
or
http://myblog.com/

Share Teach Yourself Borland C++ in 14 Days as:

From:

To:

Share Teach Yourself Borland C++ in 14 Days.

Enter two words as shown below. If you cannot read the words, click the refresh icon.

loading

Share Teach Yourself Borland C++ in 14 Days as:

Copy html code above and paste to your web page.

loading