Here is a list of the operations that can properly be performed with pointers.
Creation The initial value of a pointer has three possible sources:
Assignment
Arithmetic
Comparison
Indirection
Indexing
The following bit of code in Example 22.6 demonstrates this last point rather clearly.
Example 22.6. src/arrays/pointerIndex.cpp
#include using namespace std; int main() { int x = 23; int* px = &x; cout << "px[0] = " << px[0] << endl; cout << "px[1] = " << px[1] << endl; cout << "px[-1] = " << px[-1] << endl; return 0; } Output: src/arays> g++ pointerIndex.cc // compile & run on a Sun station src/arays> a.out px[0] = 23 px[1] = 5 px[-1] = -268437516 src/arays> g++ pointerIndex.cc // compile & run on a Linux box src/arays> ./a.out px[0] = 23 px[1] = -1073743784 px[-1] = -1073743852 src/arays> |
Part I: Introduction to C++ and Qt 4
C++ Introduction
Classes
Introduction to Qt
Lists
Functions
Inheritance and Polymorphism
Part II: Higher-Level Programming
Libraries
Introduction to Design Patterns
QObject
Generics and Containers
Qt GUI Widgets
Concurrency
Validation and Regular Expressions
Parsing XML
Meta Objects, Properties, and Reflective Programming
More Design Patterns
Models and Views
Qt SQL Classes
Part III: C++ Language Reference
Types and Expressions
Scope and Storage Class
Statements and Control Structures
Memory Access
Chapter Summary
Inheritance in Detail
Miscellaneous Topics
Part IV: Programming Assignments
MP3 Jukebox Assignments
Part V: Appendices
MP3 Jukebox Assignments
Bibliography
MP3 Jukebox Assignments