Hello. Once again I am puzzling over the code, but over what they want from me here:

Create a class in orthodox canonical form that displays a mechanical counter. The counter can take values ​​from 0 to 999. The counter has two buttons - “+” and “c”. When you press the "+" button, the counter changes to the following state:

  1. if its value is from 0 to 998, then the value will increase by one;
  2. if its value is 999, then its value will become equal to 0.

When the “c” button is pressed, the counter value becomes 0. In the class there should be member functions:

  1. the constructor with the argument is the initial value;
  2. function simulating pressing the "+" button;
  3. a function that simulates pressing the "c" button;
  4. function that returns the value of the counter.

Functions when receiving invalid arguments should issue a warning. Overload the insertion and streaming operators from the stream so that they extract and insert class objects into streams associated with binary files.

This line is incomprehensible, what they want from me here:

So that they extract and insert class objects into streams associated with binary files.

Well, what is encrypted here?

  • Serialization? о.0 - Surendil

1 answer 1

I think that the class objects are the input and output lines of the program, and it means that on Windows the threads should not be text, but binary. Those. for example, fopen ("xaxa", "r") will open the xaxa file for reading in text mode, and fopen ("xaxa," rb ") in binary .

But this is only an assumption.

Ps. setmode () in Windows (MinGW) allows you to change the flow mode.

#include <fcntl.h> setmode (1,O_BINARY); // переключить stdout setmode (fileno(stdin),O_TEXT); // переключить stdin