I have a simple class for which I want to overload operator as below
class MyClass
{
public:
int first;
template <typename T>
T operator () () const { return first; }
};
And the somewhere else I have
MyClass obj;
int i = obj(); // This gives me an error saying could not deduce
// template argument for T
Can someone help me with this error, much appreciated. Thank you.
edit:
This has something to do with the operator(), for example if i replace the function with
template <typename T>
T get() const { return first;}
it works. Appreciate all the responses.