Inheriting template class.

How to inherit template class.
I am getting some sort of error which I can not understand.How to rectify this?

// How to inherit a template class

#include<iostream>
using namespace std;

template <class T, class V>
class Mother
{
public:
void add(T x, V y)
{
std::cout << " ADD= " << x+y << std::endl;
}
};


class child:public Mother <class T, class V>
{};

int main()
{
child <int, int> c;
c.add(10,20);
return 0;
}
You need to specify the template parameter for the child class as well.
1
2
3
4
template<class T, class V>
class child :public Mother<T, V> 
{
};
Topic archived. No new replies allowed.