Skill Building Exercises

 < Day Day Up > 



  1. Research: Procure a copy of James O. Coplien's excellent book Advanced C++ Programming Styles and Idioms and read it from front to back.

  2. Default Constructor and Destructor: Given the following code for Baseline class:

    #ifndef BASELINE_H #define BASELINE_H class Baseline {  public:   virtual f();  private:   int x;   int y;   char* name; }; #endif
    • Add a default constructor that provides default values for Baseline attributes x, y, and name. Dynamically allocate memory for the name attribute.

    • Add a destructor that properly releases the memory allocated during the constructor call.

    • Write a driver program to test your code.

  3. Copy Constructors: Building upon the Baseline code of the previous exercise, add a copy constructor that creates new Baseline objects from existing Baseline objects.

  4. Copy Assignment Operator: Building upon the Baseline code resulting from the previous exercise, add a copy assignment operator to properly change the attributes of an existing Baseline object to those of another existing Baseline object. Keep in mind the difference between a shallow copy and a deep copy.

  5. Overloaded Equality Operator: Building upon the Baseline code resulting from the previous exercise, add a equality operator so that Baseline objects can be compared with each other.

  6. Overloaded Greater-Than Operator: Building upon the Baseline code resulting from the previous exercise, add a greater than operator so that Baseline objects can be compared with each other.



 < Day Day Up > 



C++ for Artists. The Art, Philosophy, and Science of Object-Oriented Programming
C++ For Artists: The Art, Philosophy, And Science Of Object-Oriented Programming
ISBN: 1932504028
EAN: 2147483647
Year: 2003
Pages: 340
Authors: Rick Miller

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net