C++ Proposed Exercises (Chapter 8: The C++ Programing Language, Fourth Edition)
C++ Proposed Exercises (Chapter 8: The C++ Programing Language, Fourth Edition)
C++ Proposed Exercises (Chapter 8: The C++ Programing Language, Fourth Edition)
In this document you can find exercises related to the content of C++ Programming Language (Fourth Edition).
Solution is provided. However, if you follow the book carefully, you will be able to solve the proposed problems
easily.
Introduction material is very dense and thats why no exercise material is elaborated.
Dont get panic If you have difficulties trying to solve these exercises. The material provided in the Introduction
section (Part I) and chapter eight, allow you to PROPOSE some solution. Some recommendations are:
1. Try to mimic the Programming Technique found in the chapter.
2. Make the program work.
3. Order struct(class) members for readability and sort them by size.
4. Declaration implies definition (initialization).
5. Test your code in main().
6. Especial attention to UML struct description.
7. Smile, you are becoming part of the C++ community.
A. struct
An struct defines by default all member public. This is why all members appears with an open lock in the UML
figure.The following UML describe the Address struct (page 202 in book). This is done with the help of metauml
(latex package).
1. Declare an Address object and print all his member elements.
2. Declare a pointer to Address object and print all his member elements.
3. In the book, we found that objects must be correctly initialize. How do you guarantee that Address object is
initialized properly ?
Address
name: const char *
street: const char *
town: const char *
zip: const char *
state: char[2]
number: int