It seems that g++ is looking for a specialized definition of blah<int> when you try to define blah::eck(). Also with the code above, if you try to declare a variable of type blah<float> and then call ugh, the link dies phase dies with an error because there is no definition for blah<float>::ugh().
The code below will compile correctly, and work in most cases...it still doesn't fix the problem with trying to call blah<anything_but_int>::ugh(). I could be way off base here, but this is the understanding I get from toying with code you posted. Hope it helps.
#include <iostream>
#include <typeinfo>
using namespace std;
template <class TYPE>
class blah
{
TYPE feh;
public:
void blech(int x);
template <class T> void gak(int x);
template <class T> void eck(int x) {};
void ugh(int x);
};
template<>
class blah<int>
{
int feh;
public:
void blech(int x) {};
template <class T> void gak(int x) {};
template <class T> void eck(int x);
void ugh(int x);
};
template <class TYPE> template <class T> void blah<TYPE>::gak(int x)
{
T a;
cout << typeid(a).name() << endl;
}
/* template <> */ template <class T> void blah<int>::eck(int x)
{
T a;
cout << typeid(a).name() << endl;
}
template <class TYPE> void blah<TYPE>::blech(int x)
{
cout << typeid(feh).name() << endl;
}
/*template <>*/ void blah<int>::ugh(int x)
{
cout << typeid(feh).name() << endl;
}
template <class T>
void foobar(int x)
{
T a;
cout << typeid(a).name() << endl;
}
int main()
{
return 0;
}
|