Skill Building Exercises

 < Day Day Up > 



  1. Create Person Project: Create a project in your IDE and test the Person class code given in examples 11.19 - 11.21. Expand on the code in the main.cpp file and create additional Person objects with different attributes. Use the new operator to create Person objects using dynamic memory allocation.

  2. Class Bar: Declare a class named Bar using the Foo class in this chapter as a guide. Declare a constructor, copy constructor, copy assignment operator, and a destructor. Declare one or more private data members and any necessary public accessor and mutator functions. Put the class declaration in a separate header file named bar.h, and the class function implementations in a file named bar.cpp. Write a main() function and test your Bar objects.

  3. Research: Do further research on different UML diagrams. Specifically, learn about statechart diagrams, object diagrams, sequence diagrams, and use case diagrams.

  4. Obtain UML Tool: Obtain a shareware UML tool or download a commercial tool for limited use. Use the Person class as a guide and define a class with the same name using the UML design tool. When you have finished the design generate the source code and examine the resulting output. How does it compare with the original Person code?

  5. Object Modeling: Examine the world around you and select several candidate objects to model in software. Determine the type of attributes and behavior each object has and translate your findings into one or more class declarations. Implement one or more or your classes and write a main() driver function to test your classes by creating and using objects. Refer to the examples in this chapter as a guide. Make sure to implement all the special class functions. Be sure to encapsulate data by declaring class data members private and class member functions public.

  6. Array of Person Pointers: Create an array of pointers to Person objects. Dynamically allocate Person objects using the new operator and assign their addresses to the array elements. Using the array elements and the “->” operator, call functions on Person objects.



 < 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