CS253 IQ 10
Show Main.IQ10 as a slide show.
fstream
Failure
When an fstream
open (explicitly, or via ctor) doesn’t work,
which bit is set?
ios::failbit
ios::eofbit
ios::badbit
ios::openbit
- None of the above
failbit
is set you ask for something, and don’t get it.
You tried to open a file, and it failed. Therefore, failbit
.
Input Conversion
When an input conversion doesn’t work, which bit is set?
ios::failbit
ios::eofbit
ios::badbit
ios::convbit
- None of the above
failbit
is set you ask for something, and don’t get it.
You tried to read something, and couldn’t. Therefore, failbit
.
Read at End
When you read the fifth byte of a five-byte file, which bit is set?
ios::failbit
ios::eofbit
ios::badbit
ios::lastbit
- None of the above
This is not an error—you read the last byte.
Sure, the next read will fail, but that’s not your problem.
Rule of Three
Which three are mentioned in the Rule of Three?
- default ctor, copy ctor, assignment, dtor
- copy ctor, assignment, dtor
- default ctor, assignment, dtor
- default ctor, copy ctor, dtor
- default ctor, copy ctor, assignment
Please tell me you didn’t pick an answer that mentioned four things.
Big Three is copy ctor, assignment, dtor.
methods
How do I get rid of the implicitly-provided assignment operator?
Foo &operator=(const Foo &) = 0;
Foo &operator=(const Foo &) = delete;
Foo &operator=(const Foo &) const;
delete Foo &operator=(const Foo &);
- Simply don’t write one.
Not writing it won’t work—it’s implicitly provided.
“Implicit” means “without asking”.
Remove it with = delete
.