>Что это за оператор?
>Почему при попытке его использования вызывается деструктор класса?
>Как этого избежать.
Good day, dear colleague. It is a function call operator.
Function call, that is, the notation expression(expressionlist), can be interpreted as a binary operation with the expression as the lefthand operand and the expressionlist as the righthand operand. The call operator () can be overloaded in the same way as other operators can. An argument list for an operator()() is evaluated and checked according to the usual argumentpassing rules. Overloading function call seems to be useful primarily for defining types that have only a single operation and for types for which one operation is predominant. The most obvious, and probably also the most important, use of the () operator is to provide
the usual function call syntax for objects that in some way behave like functions. An object that acts like a function is often called a functionlike object or simply a function object. Such
function objects are important because they allow us to write code that takes nontrivial operations as parameters. For example, the standard library provides many algorithms that invoke a function for each element of a container. Consider:
void negate(complex& c) { c= c; }
void f(vector<complex>& aa, list<complex>& ll)
{
for_each(aa.begin() ,aa.end() ,negate) ; // negate all vector elements
for_each(ll.begin() ,ll.end() ,negate) ; // negate all list elements
}
....
(c) Bjarne Stroustrup "The C++ Programming Language (special edition)"
This operator never call object destructor if you don't do this manually. Good luck!