template problem

Here is my code and and I'm having problem on main.cpp
on line cout << amarmatha.sub<int>(55,5)<<endl;

caculator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
  #ifndef CACULATOR_H
#define CACULATOR_H
template<class T>
class caculator
{
    public:
        caculator();
        T sub (T x, T y);
        T multiply (T x, T y);
        T divide (T x, T y);
        virtual ~caculator();
    protected:
    private:
};

#endif // CACULATOR_H


caculator.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include "caculator.h"


template<class T>
caculator<T>::caculator()
{
    //ctor
}

template<class T>
T caculator<T>::sub(T x, T y)
{

return x-y;

}


main.cpp
1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
#include "caculator.h"
using namespace std;

int main()
{
caculator <int> amarmatha();
 cout << amarmatha.sub<int>(55,5)<<endl;
    return 0;
}


Appreciate your help highly.. I'm very stuck with this :(
What problem?

Hint: if T==int already for amarmatha, then does a member function need to specify it again?
http://www.cplusplus.com/forum/articles/40071/#msg216270
http://www.cplusplus.com/forum/general/113904/#msg622073

Also, if `sub()' doesn't use the state of the object ┬┐why is it a member function?
Topic archived. No new replies allowed.