I have a function object A with a pair of function call operators (line 4 and 5):
class A{
public:
A(int x) : _x(x){}
int operator () () const { return _x; } // line 4
int & operator () () { return _x; } // line 5
private:
int _x;
};
Similar pair of call operators is used here. The question is: do I need line 4 at all? Does the operator defined at line 4 will ever by called? In the following case:
A a(7);
a() = 8;
cout << a() << endl;
always the operator from line 5 is called.