A
A
Arthur2018-03-13 18:40:33
C++ / C#
Arthur, 2018-03-13 18:40:33

How to define such a destructor in C++?

I received a test task in the spirit of "Implement a class with such an interface":

class LogReader
  {
public:
           LogReader(...);
          ~LogReader(...);

   bool    Open(...);                       // открытие файла, false - ошибка
   void    Close();                         // закрытие файла

   bool    SetFilter(const char *filter);   // установка фильтра строк, false - ошибка
   bool    GetNextLine(char *buf,           // запрос очередной найденной строки, 
                       const int bufsize);  // buf - буфер, bufsize - максимальная длина
                                            // false - конец файла или ошибка
  };

All my life I thought that it is impossible to pass arguments to the destructor, and even a variable number.
One might think that this should be taken as pseudo-code, but the task says that it is necessary to implement a class with such an interface.
Googling hasn't yielded any results.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2018-03-13
@Carver182

Such an interface in C++ does not make sense purely syntactically. All these ... must be replaced with something. You cannot pass arguments to the destructor. So just throw them away and don't worry.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question