I'm trying to inherit a non-template class from a template class that specified witch type I need
My code is like this:
the header file for base class(updated):
//base.hpp
template<typename T>
class Base {
public:
Base(T a,int b) :
aa(b) {
this->bb = a;
// ... some code
}
// .. some functions ( all are NOT virtual )
protected:
const int aa;
T bb;
// .. some non-constant variables
}
The header and code for derived class:
//derived.hpp
#include <SFML/System.hpp>
#iclude "base.hpp"
class Derived: public Base<sf::Vector2i> {
public:
Derived(float, int, Vector2i);
// .. other methods
protected:
// .. other variables
}
//derived.cpp
#include "derived.hpp"
Derived::Derived(float initf, int myint, Vector2i vec) :
Base(vec, myint) {
// ... some codes
}
"sf" referes to the namespac for working with SFML library. I'm using SFML 2.0 that compiled from the source using cmake
(for more information you could see: http://www.sfml-dev.org/)
When I try to compile these codes with a command similar to this:
$ g++ ./main.cpp ./derived.cpp ./base.cpp -lsfml-system
I get some linker error that tell:
In function `Derived::Derived(float, int, sf::Vector2<int>)':
undefined reference to `Base<sf::Vector2<int> >::Base(sf::Vector2<int>, int)'
Also I'm using "g++ (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3" as my C++ compiler with C++11 enabled.