samedi 4 mars 2017

expression preceding parentheses of apparent call must have (pointer-to-) function type

I am learning C++ template on vs2015 community.Here is my code ,i want to define a template class and call the member function in the main function.

template <typename T>
class Arithmetic {
    T _a;
    T _b;
    Arithmetic() {};
public
    Arithmetic(T a, T b) :_a(a), _b(b) {};
    T max const() { return _a + _b; };
    T minus const() { return _a - _b; };
};

int main() {
    Arithmetic<int> ar(5,6);
    cout << ar.max() << endl;
}

When i build,i get error at the last line.It says"expression preceding parentheses of apparent call must have (pointer-to-) function type".What should i do?

Aucun commentaire:

Enregistrer un commentaire