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

产品代码
978-0-470-31726-6
下载
页码 12
C++ For Dummies, 6th Edition 
xiv
Constructing Class Members ..................................................................... 224
Constructing a complex data member ............................................ 224
Constructing a constant data member ........................................... 228
Reconstructing the Order of Construction .............................................. 229
Local objects construct in order ..................................................... 229
Static objects construct only once .................................................. 230
All global objects construct before main()..................................... 231
Global objects construct in no particular order ............................ 231
Members construct in the order in which they are declared ...... 233
Destructors destruct in the reverse order of the constructors... 233
Constructors as a Form of Conversion ..................................................... 233
Chapter 17: Copying the Copy Copy Copy Constructor  . . . . . . . . . . . .235
Copying an Object ....................................................................................... 235
Why you need the copy constructor ............................................... 236
Using the copy constructor .............................................................. 236
The Automatic Copy Constructor ............................................................. 238
Creating Shallow Copies versus Deep Copies .......................................... 240
It’s a Long Way to Temporaries ................................................................. 244
Avoiding temporaries, permanently................................................ 246
Chapter 18: Static Members: Can Fabric Softener Help?  . . . . . . . . . .247
Defi ning a Static Member ............................................................................ 247
Why you need static members ......................................................... 247
Using static members ........................................................................ 248
Referencing static data members .................................................... 249
Uses for static data members ........................................................... 250
Declaring Static Member Functions .......................................................... 251
What Is This About Anyway? ..................................................................... 253
Part IV: Inheritance .................................................. 255
Chapter 19: Inheriting a Class  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .257
Do I Need My Inheritance? ......................................................................... 258
How Does a Class Inherit? .......................................................................... 259
Using a subclass ................................................................................. 261
Constructing a subclass .................................................................... 262
Destructing a subclass ...................................................................... 263
Having a HAS_A Relationship ..................................................................... 263
Chapter 20: Examining Virtual Member Functions: 
Are They for Real?  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .265
Why You Need Polymorphism ................................................................... 268
How Polymorphism Works ......................................................................... 269
When Is a Virtual Function Not? ................................................................ 270
Considering Virtual Considerations .......................................................... 271