Which statement about combining C++ file-opening modes is correct?

Options

  • A. File modes can be combined using the bitwise OR operator |
  • B. File modes can only be used one at a time
  • C. ios::binary always implies ios::trunc
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

A. File modes can be combined using the bitwise OR operator |

Detailed Explanation

Correct Answer: Option A

Explanation: File-opening modes can be combined with the bitwise OR operator. For example, ios::in | ios::binary opens a file for binary input. Adding ios::trunc requests truncation where supported by the stream opening operation.