MFC Programmer's SourceBook : Thinking in C++
Bruce Eckel's Thinking in C++, 2nd Ed Contents | Prev | Next

Exercises

  1. Take Exercise 2 from Chapter 6, and add an inline constructor, and an inline member function called print( ) to print out all the values in the array.
  2. Take the NestFriend.cpp example from Chapter XX and replace all the member functions with inlines. Make them non- in situ inline functions. Also change the initialize( ) functions to constructors.
  3. Take the nl.cpp example from Chapter XX and turn nl into an inline function in its own header file.
  4. Create a class A with a default constructor that announces itself. Now make a new class B and put an object of A as a member of B, and give B an inline constructor. Create an array of B objects and see what happens.
  5. Create a large quantity of the objects from Exercise 4, and use the Time class to time the difference between a non-inline constructor and an inline constructor. (If you have a profiler, also try using that.)
Contents | Prev | Next


Go to CodeGuru.com
Contact: webmaster@codeguru.com
© Copyright 1997-1999 CodeGuru