For Dummies C++, 6th Edition 978-0-470-31726-6 用户手册

产品代码
978-0-470-31726-6
下载
页码 12
xiii
 Table of Contents
Keeping a Member Function After Class .................................................. 176
Overloading Member Functions ................................................................ 178
Chapter 13: Point and Stare at Objects. . . . . . . . . . . . . . . . . . . . . . . . . .181
Declaring Arrays of Objects ....................................................................... 181
Declaring Pointers to Objects .................................................................... 182
Dereferencing an object pointer ...................................................... 183
Pointing toward arrow pointers ....................................................... 184
Passing Objects to Functions ..................................................................... 184
Calling a function with an object value ........................................... 185
Calling a function with an object pointer ....................................... 186
Calling a function by using the reference operator ....................... 188
Why Bother with Pointers or References? ............................................... 189
Returning to the Heap ................................................................................. 189
Allocating heaps of objects .............................................................. 190
Comparing Pointers to References ............................................................ 191
Linking Up with Linked Lists ...................................................................... 191
Performing other operations on a linked list ................................. 192
Hooking up with a LinkedListData program ................................... 193
A Ray of Hope: A List of Containers Linked to the C++ Library ............. 196
Chapter 14: Protecting Members: Do Not Disturb  . . . . . . . . . . . . . . . .197
Protecting Members .................................................................................... 197
Why you need protected members ................................................. 197
Discovering how protected members work ................................... 198
Making an Argument for Using Protected Members ............................... 200
Protecting the internal state of the class ........................................ 200
Using a class with a limited interface .............................................. 201
Giving Nonmember Functions Access to Protected Members .............. 201
Chapter 15: Why Do You Build Me Up, 
Just to Tear Me Down Baby? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .205
Creating Objects .......................................................................................... 205
Using Constructors ...................................................................................... 206
Constructing a single object ............................................................. 207
Constructing multiple objects .......................................................... 208
Constructing a duplex ....................................................................... 209
Dissecting a Destructor .............................................................................. 211
Why you need the destructor .......................................................... 211
Working with destructors ................................................................. 212
Chapter 16: Making Constructive Arguments . . . . . . . . . . . . . . . . . . . .217
Outfi tting Constructors with Arguments .................................................. 217
Using a constructor ........................................................................... 218
Placing Too Many Demands on the Carpenter: 
Overloading the Constructor ................................................................. 220
Defaulting Default Constructors ................................................................ 222