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.

Chapter 17: Making Constructive Arguments 237class Student{public:Student (int id, int age) : sAge(age), sId(id){}const int sId;const int sAge;};In this example, sId is constructed before sAge, even though sId appearssecond in the constructor’s initialization list. The only time you might detecta difference in the construction order is when both data members are aninstance of a class that has a constructor that has some mutual side effect.Destructors destruct in the reverseorder of the constructorsFinally, no matter in what order the constructors kick off, you can be assuredthat the destructors are invoked in the reverse order. (It’s nice to know thatat least one rule in C++ has no ifs, ands, or buts.)

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

Saved successfully!

Ooh no, something went wrong!