Помогите заставить видеть реализацию метода bar()
$ cat foo.hpp
#ifndef QWERTY123
#define QWERTY123
namespace XYZ {
template<class T> class Foo {
public:
T x;
virtual void bar() = 0;
};
template<class T> class Bar: public Foo<T> {
virtual void bar() final;
};
}
#endif
$ cat foo.cpp
#include <iostream>
#include "foo.hpp"
namespace XYZ {
template<class T>
void Foo<T>::bar(){ std::cout << "bar print: " << x << std::endl; }
template<> class Foo<float>;
template<> class Foo<int>;
}
$ cat main.cpp
#include <iostream>
#include "foo.hpp"
int main()
{
XYZ::Bar<int> f;
f.x=25;
std::cout << f.x ;
}
$ g++ -std=c++11 -c foo.cpp
$ ar crs libfoo.a ./foo.o
$ g++ -std=c++11 main.cpp -L./ -lfoo && ./a.out
undefined reference to `XYZ::Bar<int>::bar()'
collect2: error: ld returned 1 exit status