Template Subclass

closed account (o1vk4iN6)
I am trying to create a class with a template and than subclass it like so:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

template<class T>
class A : public D { //D is defined else where and I am subclassing it as well
protected:
    T* data;

public:
    A(int);
    ~A();
};

template<class T>
A<T>::A(int x) : D(x) { ... }

template<class T>
A<T>::~A() { ... }


Than I have my class which subclasses it:

1
2
3
4
5
6
7
8
9

class B : A<float> {
public:
     B(int);
     ~B();
};

B::B(int x) : A(x) { ... }
B::~B() : ~A() { ... }


I keep getting an unresolved external symbol for A<float>::A() and A<float>::~A().

Thanks for any help.

Last edited on
Template functions have to be declared and defined in the header.

Man, I've lost count of how many times I've said this already.
Topic archived. No new replies allowed.