Skip to Content
Navigating C++ and Object-Oriented Design
book

Navigating C++ and Object-Oriented Design

by Paul Anderson, Gail Anderson
October 1997
Intermediate to advanced
800 pages
20h 48m
English
Pearson
Content preview from Navigating C++ and Object-Oriented Design

13.10. Exercises

1: Design a Double class that overloads the division operator for Double objects and built-in types. Under what conditions should the division operator throw exceptions?
2:Implement the copy constructor and overloaded assignment operator in class FilePtr (Listing 13.18 on page 636). Follow the approach shown in auto_ptr (Listing 13.15 on page 627). What helper functions do you need?
3:Add FBadRead and FBadWrite exceptions to the FileError exception hierarchy in Listing 13.19 on page 636. Use the mycp.C program (Listing 13.20 on page 637) to test your solution and make it behave as follows.
$ mycp file1 file2 
Unable to open file file1 for access "r"
(File not readable or does not exist)

$ mycp myfile /etc/passwd Unable to open ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Exploring C++20: The Programmer's Introduction to C++

Exploring C++20: The Programmer's Introduction to C++

Ray Lischner

Publisher Resources

ISBN: 0135327482Purchase book