1

So this is my first time using headers so please be gentle...

I've got a base class defined in a header file (base.h) with its member functions defined in a matching .cpp file (base.cpp). I have another header file with a derived class (derived.h) and again member functions defined in its .cpp file (derived.cpp). For some reason, the linker can't find any of the base class functions when they're used in derived.cpp. I've searched a lot but can only find problems relating to external headers. Where am I going wrong?

base.h:

    template <typename T> class base {
    /*protected and public member functions and private data*/
    protected: 
        base();
    };

base.cpp:

    #include "base.h"
    template <typename T> base<T>::base() : /*initialise member data*/ {}

derived.h:

    #include "base.h"
    class derived : public base<double> {
    /*public member functions*/
    public: 
        derived();
    }

derived.cpp:

    #include "derived.h"
    #include "base.h"
    derived::derived() : base() {}

This gives me the linker error that base<double>::base<double>(void) is an unresolved external symbol when building derived.obj

frankbrews
  • 21
  • 1

0 Answers0