2.3 What is so bad about C++?

Isn't the automatic invocation of the constructor method a good thing, to make sure variables are always initialized?

In most cases, the answer is yes. However, there are cases in which the proper initialization of a variable cannot be determined until later. In C, we can simply defer the initialization until it is clear how the variable should be initialized. In C++, however, we'll initialize the variable using defaults first, then alter the variable later on based on program logic.

The C code is more efficient (both in terms of code size and run-time), although the difference is probably fairly small. Nonetheless, in an architecture that has very little resources, the difference can be significant.



Copyright © 2006-09-05 by Tak Auyeung