11.07.2015 Views

tYSR20

tYSR20

tYSR20

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

xC++ For Dummies, 5th EditionChapter 16: “Why Do You Build Me Up, Just to Tear Me Down, Baby?” . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .209Creating Objects...........................................................................................209Using Constructors ......................................................................................210Why you need constructors..............................................................210Making constructors work ................................................................212Dissecting a Destructor ...............................................................................217Why you need the destructor...........................................................217Working with destructors..................................................................217Chapter 17: Making Constructive Arguments . . . . . . . . . . . . . . . . . . . .221Outfitting Constructors with Arguments ..................................................221Justifying constructors......................................................................222Using a constructor............................................................................222Placing Too Many Demands on the Carpenter:Overloading the Constructor..................................................................223Defaulting Default Constructors.................................................................227Constructing Class Members......................................................................228Constructing a complex data member ............................................228Constructing a constant data member ............................................232Constructing the Order of Construction ...................................................233Local objects construct in order ......................................................234Static objects construct only once ..................................................234All global objects construct before main( ) ....................................235Global objects construct in no particular order ............................235Members construct in the order in which they are declared.......236Destructors destruct in the reverse order of the constructors.........................................................................237Chapter 18: Copying the Copy Copy Copy Constructor . . . . . . . . . . . .239Copying an Object........................................................................................239Why you need the copy constructor ...............................................239Using the copy constructor ..............................................................240The Automatic Copy Constructor..............................................................242Creating Shallow Copies versus Deep Copies ..........................................244It’s a Long Way to Temporaries ..................................................................248Avoiding temporaries, permanently ................................................249Referring to the copy constructor’s referential argument ............250Chapter 19: Static Members: Can Fabric Softener Help? . . . . . . . . . .251Defining a Static Member ............................................................................251Why you need static members .........................................................251Using static members ........................................................................252Referencing static data members.....................................................253Uses for static data members ...........................................................255

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!