Problem :
I am very new to C++ and trying to learning C++ template. Please find below my code, I am trying to define a template class and also want to call the member function in the main() method..
template <typename T>
class Calculate {
T _x;
T _y;
Calculate () {};
public
Calculate (T x, T y) :_x(x), _y(y) {};
T add const() { return _x + _y; };
T sub const() { return _x - _y; };
};
int main() {
Calculate <int> ar(7,8);
cout << ar.add() << endl;
}
But whenever I try to build this program, I am getting following error at the last line of above code :
Expression preceding parentheses of apparent call must have (pointer-to-) function type
How can I resolve this issue?