What's Next

By now, you should have a good idea about what happens behind the scenes in C++. You are slightly at the mercy of the system until you appreciate what C++ does for you silently and why it is sometimes wrongheaded. One good way to get a feeling for what C++ does is to single-step through you first C++ programs with a debugger, looking at all the functions you went through. It's a good idea to play with C++ to learn more about it, and UnderC makes that less painful. You can learn a lot by tracing all function calls. In UnderC, you do this as follows, by using the #opt command to switch on t (for trace) and v (for verbose):

;> #opt t+ v+
;> s
						=
						"hello";
*sig:   void operator=(char*)
*match: string& operator=(char*)
*TRACE <temp>
*TRACE =
*TRACE copy
*TRACE strlen
*TRACE resize
*TRACE _new_vect
*TRACE strcpy
*TRACE strcpy
(string&) 'hello'
;> #opt t- v-
					

If you repeat this with string s = "hello", you will indeed see that __C__ (that is, the constructor) is called instead of operator=.

Chapter 10, “Templates,” deals with templates. You have already begun using templates because all the standard containers are template classes. Templates offer a powerful way to reuse code because they enable you to generate functions and classes automatically for each specified type.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.70.247