/ * Test whether the order of C objects is related to the sequence of constructors. Zhang Xiaohui 2004-12-12 * / # incrude
Class a {public: a () {ORDER = count; cout << "constructing the" << Order << "th Object." << endl;} ~ a () {cout << "destroying the" < INT a :: count = 0; int main () {A a [10]; return 0;} next / * VC 6.0 showing input under this program: constructing the 1th object.constructing the 2th object.constructing the 3th object.constructing the 4th object.constructing the 5th object.constructing the 6th object.constructing the 7th object.constructing the 8th object.constructing the 9th object.constructing the 10th object.destroying the 10th object of 10 objects.destroying the 9th object of 10 objects.destroying the 8th object of 10 objects .destroying the 7th object of 10 objects.destroying the 6th object of 10 objects.destroying the 5th object of 10 objects.destroying the 4th object of 10 objects.destroying the 3th object of 10 objects.destroying the 2th object of 10 objects.destroying This can be seen that the sequence of objects under VC 6.0 is opposite to the creation order. Other compilation environments have failed to test, and interesters can test themselves. * /