An MFC-based Dynamic Link Library

Chapter 10 - Using Pointers

Visual C++ 6: The Complete Reference
Chris H. Pappas and William H. Murray, III
  Copyright 1998 The McGraw-Hill Companies

Chapter 10: Using Pointers
Overview
Unless you have taken a formal course in data structures, you have probably never encountered pointer variables. Pointer variables take the normally invisible memory address of a variable and bring it into the foreground. This can make for extremely efficient algorithms and definitely adds some complexity to your coding. It’s similar to the difference between an automobile with an automatic transmission (or static variables—see definition below) versus a manual transmission (or dynamic variables—see definition below). So, while with a manual transmission you have the ability to select just the right gear at the right time, you also need to know how to clutch! And if you remember back to the first time you attempted to drive a stick shift, you know there were a few bumps and grinds until you perfected your skill.
In C/C++, the topics of pointers, arrays, and strings are closely related. Consequently, you can consider this chapter to be an extension of Chapter 9. Learning about pointers—what they are and how to use them—can be a challenging experience to the novice programmer. However, by mastering the concept of pointers, you will be able to author extremely efficient, powerful, and flexible C/C++ applications.
It is very common practice for most introductory-level programs to use only the class of variables known as static. Static variables, in this sense, are variables declared in the variable declaration block of the source code. While the program is executing, the application can neither obtain more of these variables nor deallocate storage for a variable. In addition, you have no way of knowing the address in memory for each variable or constant. Accessing an actual cell is a straightforward process—you simply use the variable’s name. For example, in C/C++, if you want to increment the int variable idecade by 10, you access idecade by name:
idecade += 10;

Books24x7.com, Inc 2000 –  


Visual C++ 6(c) The Complete Reference
Visual Studio 6: The Complete Reference
ISBN: B00007FYGA
EAN: N/A
Year: 1998
Pages: 207

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net