No protection just data hiding no level 2 adjust the

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: s asked to be stored is stored. (no protection - just data hiding) (no Level 2 Adjust the values passed so that the resulting Adjust stored values are valid. Applied Programming Level 3 any invalid value is rejected, with an error any message printed and program terminated message if (secs < 0 || secs > 59 || mins < 0 || mins > 59 || hrs < 0 || hrs > 23) { cerr << "Illegal time value\n."; exit(1); // bad value exit } The header cstdlib should be included for the The cstdlib should exit() function. exit() Applied Programming We will use levels 1 to 3. Let's move on. void TimeType::Increment() void TimeType::Increment { seconds++; if (seconds == 60) { seconds = 0; minutes++; if (minutes == 60) { minutes = 0; hours++; if (hours == 24) hours = 0; } } } Applied Programming Applied Programming Level 4 any invalid value causes an exception, jjust like any exception ust overflows, underflows and divisions by zero in the built-iin datatypes. built n datatypes Exception handling is a very import...
View Full Document

Ask a homework question - tutors are online