244 Part III
ch = in_file.get();
serial_out.put(ch);
}
serial_out.fflush();
Answer 66: The
setjmp
marks a location in the code. The
longjmp
call jumps to it.
It jumps directly to it, it does not pass go, it does not collect $200. It also
skips all the destructors for all the variables on the stack. In this case,
because the destructor for
std::string
returns the memory allocated for the
string, we have a memory leak.
That’s because the
setjmp
and
longjmp
functions are C functions that should
not be used in C++.
Avoidance 21: Do not use
setjmp
and
longjmp
in a C++ program. Use exceptions
instead.
Answer 67: In the default case:
defualt:
std::cout << i << " is not prime\n";
break;
The “default” keyword is misspelled. The result is that the C++ comp ...