If you want to know whether you should buy this book, read thisintroduction!First question: Why learn C++ at all? That's easy: It’s today’s dominantcomputer language. When the going gets tough, the professionals turn toC++. There are many other languages, of course, but they lack theuniversality and power of C++. For example, Visual Basic is useful forquickly putting together applications that aren’t too large or demanding,assembly language is good if you’re writing a device driver, and Java isgreat for the World Wide Web. (Java is derived from C++ anyway.) But fora major standalone application, C++ is the most popular language that hasthe power and flexibility to produce the fastest, best-performing code. Forthese reasons, C++ is a major part of the Computer Science curriculum atalmost every school and university. If you’re a programmer, chances arethat sooner or later you’ll need to know it.
What’s Different About This Book?
This book is a C++ tutorial. But there are a lot of C++ tutorials on themarket. How is this one different? Three ways: It’s easy to understand, it’sorganized in a better and unique way, and it comes with a free backupsystem if there’s anything that’s giving you trouble. Let’s look at thesefeatures in detail.
Easy to Understand
This book starts off with very easy examples; we don’t assume you’re arocket scientist. We try to explain everything with no assumptions aboutwhat you may already know. We use plenty of figures and analogies toclarify the text. The program examples are heavily commented to makeeverything as clear as possible.As you progress further into the book, the examples become morechallenging, but we try to keep the increase in difficulty gradual, so you’realways ready for what comes next. Ultimately we cover all the mainfeatures of C++.
Unlike most other C++ books, this one uses, from the very first example,real object-oriented programs. Most books, in an attempt to stick with thefamiliar, start with old-fashioned procedural examples and work up to fullobject-based examples half-way through. This may seem easier, but in thelong run it’s counter-productive, because it encourages bad thinking habits.The whole point of C++ is to write object-oriented programs. If they don’tdo that from the beginning, they’re missing the point. And, as it turns out,object-oriented programs aren’t that hard anyway.
The Waite Group Interactive Series
The third way this book differs from other C++ books is that it’s a WaiteGroup Interactive book. This isn't just publisher’s hype: By connecting youto the Waite Group via the World Wide Web, this new approach canactually play a significant role in helping you to learn C++. There are manyaspects to the Interactive Series. We won’t dwell on them here, since thedetails are presented elsewhere. We should note, however, that this book was written from the ground up to work as part of the Interactive Series.First, each chapter is divided into short, easily digestible lessons. Eachlesson is devoted to a specific topic and requires only an hour(approximately) to read and understand. This makes it easy to sit down withthe book and learn something, even if your time is limited.Each lesson is followed by a quiz to ensure that you’ve understood thematerial. You can answer the quizzes by yourself, or you can do them onthe Web, which will grade them automatically. There are almost 500 quizquestions in the book, so you'll really find out how well you understand thesubject.The Waite Group Web site offers many other advantages. A principle one ismentoring, which is the ability to ask questions and get answers back, justas you would if you were taking a class at a university and could talk to theprofessor.As a final plus, this book includes a full chapter on the Standard TemplateLibrary (STL), which is fast becoming an essential part of every C++programmer’s bag of tricks, but which has not yet made its way into manyC++ books.
What Do You Need to Know?
This book is intended for anyone who wants to learn C++ from the groundup. That is, it does not assume any previous knowledge of C (or any otherspecific programming language). It’s nice if you’ve had some exposure toanother language, but even that is not essential. In fact, it may be better notto have bad old (procedural) habits to unlearn.If you already know the C language, you’ll find that perhaps a third of thematerial in this book is familiar to you. You’ll know the basic syntax of
statements, and pointers, for example. However,you’ll be surprised by how much of the material is new. Almost all theexamples, including those that explain basic syntax, use the object-orientedapproach, so you’ll find you’re learning OOP even when you’re readingabout syntax you already know.
What Hardware and Software Do You Need?
You should have some kind of C++ compiler at your disposal. The exampleprograms in this book are—for the most part—generic: That is, they willwork with most compilers. Thus, you aren’t constrained to use anyparticular system.In a few instances we wrote compiler-specific code so we could use moresophisticated screen displays. This applies to only a half-dozen examplesout of more than 200 programs in the book. For these, the code in the book is specific to Borland C++ (and Turbo C++, which is similar). These areprobably the most popular compilers and among the easiest to use.However, if you're using Microsoft Visual C++, Appendix C shows youhow, by inserting a special header file (provided on the CD-ROM) into theexample’s source code, you can easily convert these few programs to work with your compiler.
Go For It!
Learning C++ has never been easier. With its short lessons,easy-to-understand writing style, and the support of Waite Group Press viatheir Web site, you should be on your way to C++ mastery in less time thanyou thought possible.
The companion CD-ROM contains all of the source code and theexecutables from the lessons in the book, as well as the NetManageChameleon installer. Since all of the code for the lessons in this book are onthe companion CD-ROM, there is no need to type the code if you want touse it for your own projects. We will illustrate how to copy the files fromthe companion CD-ROM to your hard drive.This section will walk you through the steps necessary to install the sourcecode from the CD-ROM to your hard drive for DOS/Windows 3.x andWindows 95. To install the NetManage Chameleon, please see the section
The Chameleon Sampler
For the following examples, we are going to assume that theCD-ROM drive you want to copy files from is the D: drive and the harddrive you want to copy files to is the C: drive. If your system is set updifferently, please substitute the appropriate drive letters for your system.
These instructions for DOS assume you have no familiarity with DOScommands. If you feel uncomfortable with DOS and are using theseinstructions from the Windows DOS Prompt, please exit and follow theinstructions for your version of Windows.
Move to the drive that you want to copy the files to. If you want tocopy the files onto the C: drive, type
and press ENTER. Ensure you are at the root directory by typing
and pressing ENTER.
Create the directory you would like to store your files into. If youwant to store the files into the CPPIC directory, type
and press ENTER.
Move to that directory. If you created a directory called CPPIC,move to that directory by typing
and press ENTER.
To copy all of the files to your hard drive, simply type
XCOPY D:\*.* /V /S
and press ENTER. To copy individual subdirectories from theCD-ROM to the CPPIC directory on your hard drive, you must createthe chapter directories before you copy the contents. For example, if you wanted to copy the code for Chapters 2, 5, and 7, you would type
MD CHAP_02MD CHAP_05MD CHAP_07
and press ENTER after each line. Then you would type
CD \CPPIC\CHAP_02XCOPY D:\CHAP_02 /V /SCD \CPPIC\CHAP_05XCOPY D:\CHAP_05 /V /SCD \CPPIC\CHAP_07XCOPY D:\CHAP_07 /V /S
and press ENTER after each line. The /V is a DOS switch to verifyfiles while copying and /S is a DOS switch to copy thesubdirectories. Depending on the configuration and performance of your system, these steps may take from a few moments to a fewminutes.
The following steps are for the use of Windows 3.x with short file names.
Open the File Manager.
In File Manager, locate the drive you want to copy to and click onit.
If you have a directory to copy the files to, skip to Step 4.Otherwise, create a new directory by selecting File, Create Directory.Type
or a directory name of your choice and press ENTER or click on theOK button.
Click on CPPIC or the directory you created.
Select the drive letter of your CD-ROM drive.
Double-click on the D: drive icon. You should see the followingdirectory structure:
Control-click on the directories that you want to copy and drag theselection to the destination drive. Depending on how fast yourcomputer is and also depending on the options set for your computer,the copying process may take a few moments to a few minutes.
When Windows copies a CD-ROM, it does not change theRead-only attribute for the files it copies. You can view the files, but youcannot edit them until you remove this attribute. To change it on all of thefiles, select the top-most directory with the files in it. In File Manager,select File, Properties and click on the Read-only checkbox to deselect itand click on OK.
The easiest way to copy files using Windows 95 is by using the Desktop.
Double-click on the My Computer icon. Your drives will appearin a window on the desktop.
Double-click on your hard drive and create a new folder, such as
C++ Interactive Course
, by selecting File, New, Folder from thewindow menu. A folder called
will be created on yourhard drive with the name highlighted. Type in the name you want andpress the ENTER key.
Go back to your drive window and double-click on the icon thatrepresents your CD-ROM. You will see a window that has 11 chapterfolders, one appendix folder, and one Program folder.
Select the directories you want to copy (control-click on thefolders if you’re not copying all of them) and drag your selection tothe directory you created on your hard drive. You might need toreposition your windows to make the window for your hard drivevisible. Depending on your system’s performance, this may take afew moments to a few minutes
When Windows (any version) copies a CD-ROM, it does notchange the Read-only attribute for the files it copies. You can view thefiles, but you cannot edit them until you remove this attribute. To changeit on all of the files, select the top-most directory with the files in it. InExplorer, select File, Properties and click on the Read-only checkbox todeselect it and click on OK.
The Chameleon Sampler
The NetManage Internet Chameleon is one of the most versatile andeasy-to-use set of Internet tools in the world. Chameleon helps you sign upwith an Internet provider, connect cleanly to the Internet, and access avariety of resources—including a pretty cool Web browser. The Chameleonpackage includes
for connecting to the Internet
a full-featured World Wide Web browser
which lets you access any gopher menu worldwide
a Usenet newsreader
a convenient way to send and receive e-mail
which lets you search for a file over the Internet
for connecting to a remote computer
for transferring files over the Internet
which lets you allow others to download or uploadfiles to your PC
programs that help you compact or organize yourmailbox files to save space
to test if you’re connected to a remote computer
to check if a friend is connected to the Internet
to get information about people registered in the NIC(Network Information Center) databaseYou can sample the Chameleon tools for 30 days at no charge. If you likewhat you see, you can register everything for 50 bucks.
Installing the Chameleon
In the installation directions here, we assume that your hard disk isthe C: drive and your CD-ROM is the D: drive. If this doesn’t match yourcomputer, substitute C: or D: with the correct drive designation.
To copy the sampler software onto your hard disk, run the Setup program.While under Windows, select File, Run in the Program Manager. In theRun dialog box, type
and then press the OK button.The Setup program will ask you where to install the NetManage program.The default suggested is fine for most people. If you want it installedelsewhere, type in the drive and directory of your choosing and selectContinue.After a few moments, the Setup program will ask you to type in the path of the second batch of files. Select the 1 in
and change it to 2, andselect Continue.After another few moments, the Setup program will ask you to type in thepath of the third batch of files. Select the 2 in
and change it to 3,and select Continue.Click OK when Setup tells you that installation is complete. You are nowready to setup your Internet account!
Signing Up for an Internet Provider Account
If you don’t already have one, the Chameleon package makes it easy to signup with one of several popular Internet providers. Read Chapter 1 for moreinformation about what services are offered by Internet providers.If you’d like to sign up using the Chameleon software, run the AutomaticInternet-Click to Start icon.To learn about a particular Internet provider, click one of the tabs (otherthan NetManage) in the Select Internet Provider window. Most providersgive you several hours (or even a month) of free trial time. To read aboutthe locations an Internet provider can cover, the monthly price, and otherimportant information, click the More Info button at the bottom of thescreen. If you have specific questions, contact the provider directly.When you’re ready to begin the sign-up procedure, click the Signup button.You’ll see a registration screen similar to the one in Figure I-1. Fill in yourname (as it appears on your credit card), address, phone number, and creditcard information.
The easiest way to sign up for an Internet provider
You will not actually be charged any provider fees until youofficially register with the service. You can cancel the registrationtransaction at any time during the sign-on process. If you do decide toregister, your credit card number will be sent over a secure phone line.
As you work through the sign-up process, there may be other tabs askingfor additional information. If so, click these tabs and fill in the forms.Select the Phone List button at the bottom of the screen. The Phone Listdialog appears, listing possible phone numbers you can use to register. If one of the numbers is in your area code, select it. Otherwise, select thetoll-free 800 number.
If necessary, you can edit the registration phone number. Somesystems, for example, require you to dial a 9 to reach an outside line. Justtype in this 9.
When you’ve typed in all your vital stats, return to the first registration tab.Click Send to dial the toll-free number and begin the registration process.The icons to the right will light up as each stage of the dialing process iscompleted. The set of traffic lights tell you if each stage—initializing themodem, dialing, connecting, and communicating—has worked.
You may need to click the Advanced button to specify specialmodem ports or commands.
Follow the instructions that appear as the registration proceeds. You will begiven the option to select from various service and pricing plans. Youraccount information (username, e-mail address, password, dial-up number,and IP address) will automatically be configured into the Chameleonpackage. An interface will be created for the Custom program, whichquickly and flawlessly connects you to the Internet.That’s it! You can now reboot your system to kick-start everything.
Registering the Chameleon Software
If you already have an Internet account, you can set up the InternetChameleon software (shown in Figure I-2) and start using it within minutes.Run the Automatic Internet-Click to Start program.
The full Chameleon package in the Internet Chameleonprogram groupMake sure the NetManage tab is selected, and then click the Signup button.You can now activate the software for a free 30-day demonstration period.After this period, the Chameleon software will no longer work. If youdecide to register the Chameleon package (for $50), your credit card will becharged and your software will be activated permanently.Fill in all the information on both forms, as shown in Figure I-1, includingyour credit card number (it won’t be charged unless you complete theregistration). You may need to contact your Internet provider for theInternet information on the second form.Select the Phone button, and choose a local or toll-free phone number. Thenclick the Send button to dial in to NetManage and get your softwareactivated.Once you connect, you are given the following choices:
Activate your software for a free 30-day demonstration.
Purchase your software to activate it permanently.
Configure your connection (if your Chameleon software hasalready been activated).
Connecting to the Internet
Now that you have selected a provider and registered your software, youcan actually get hooked in to the Internet. To do this, you need to run theCustom program (Figure I-3) from Windows File Manager.
Your customized on-ramp onto the Information SuperhighwayIf you used the Chameleon package to sign up with your Internet provider,an automatic configuration file should have already been written for you.Otherwise, Chameleon comes with the configurations for most popularInternet providers. Select File, Open and look for the configuration file foryour provider. If your provider is not listed, you’ll need to contact them andask what the proper settings are. They may even be able to send you aprewritten Chameleon configuration file.If you do need to enter the connection settings yourself, use the appropriatevalues you have obtained from your Internet provider. You can verify oredit the following information under the Setup menu:
BOOTPYou may also need to fill in the following under the Services menu:
Domain ServersRead Chapter 1 for more information about these terms.
Once your configuration settings are in place, simply click the Connectmenu to dial up your Internet provider and get connected. If all goes well,you should hear a small beep, and a program known as Newt will run. Thisprogram lets Windows communicate with the Internet. You can thenminimize the Custom program and run the Internet application of yourchoice.
When you’re done using the Internet, call up the Custom program and click the Disconnect menu.
Web Browsing with Websurfer
WebSurfer is a full-featured World Wide Web browser similar to Mosaic.You can read all about browsers in Chapter 2 and about Mosaic in Chapter5. To start exploring the Web, first use the Chameleon Custom program toconnect to the Internet. Then run the WebSurfer program.Like Mosaic, WebSurfer has a toolbar (see the top of Figure I-4) that acts asa shortcut for most commands. The toolbar contains
The WebSurfer browser in all its glory
Show Connection Status: Shows you which links are currentlybeing loaded.
Go to URL: Opens a specific Web URL (defined in Chapter 1).
Get URL: Reloads the current document.
Hotlist: Shows the list of your favorite Web pages for you tochoose from. To go to a page, just double-click on it. You can alsodelete pages from the list by selecting the page and clicking Remove.
Make Hot: Adds the current Web page to your hotlist.
Back: Revisits the Web page you just came from.
Forward: Goes to the next Web page in the series, if applicable.
Home: Returns to the Web page you started from.
Cancel All: Stops the loading of the current Web page.
Loading a Web Page from the Internet
Like Mosaic, WebSurfer combines text and graphics on the same page. Anytext in blue or graphics with a blue border are hypertext
links to other Webpages, multimedia files, or Internet areas. To load a link, just click on it.You can also load up a document directly. Just select Retrieve, Go To URLand type in the document’s exact URL. Alternatively, you can type adocument’s URL in the Dialog bar’s URL box and press to loadit.If the document is a Web page, it will be displayed. If the document is agraphic, sound, or movie, the WebSurfer program will attempt to call up aviewer program to display/play it. If the document is any other type of multimedia file, WebSurfer allows you to save the document directly toyour hard disk.To find out more about the current Web document, select Retrieve,Properties.
Loading a Web Page from Your Hard Disk
If you have any Web pages on your hard disk (perhaps ones that you’vecreated yourself), you can easily use WebSurfer to view them. SelectRetrieve, Open Local File. Choose the file you want to view and click OK.You can even edit the current Web document—a very handy capability forWeb developers. Select Retrieve, Edit HTML. Then access the Retrieve,Refresh From Disk menu item to reload the page in a flash and see whatyour edits look like.
Other Internet Tools
The Chameleon package contains software for every Internet resource youcould possibly want. To use FTP, e-mail, telnet, gopher, or any otherInternet program, first connect to the Internet using the Custom application.Then you can communicate with friends across the world using Mail, reador post messages to thousands of newsgroups using NEWTNews, browsemenus of data using gopher, download tons of cool software using FTP, andmuch moreTable of Contents
ference/archive/1571690638/index.html [21-03-2000 18:54:05]