Here's the code:
class PureDummy
{
public:
virtual void foo() = 0;
template<class T>
void bar();
};
class Dummy : public PureDummy
{
public:
virtual void foo()
{
}
template<class T>
void bar()
{
}
};
int main(int argc, char **argv)
{
PureDummy *pdummy = new Dummy();
pdummy->foo(); //OK
//pdummy->bar<int>(); //undefined reference to `void PureDummy::bar<int>()'
}
So as a comment states, with a call to bar compilation fails.
Why does the template function exhibit different behavior from a "regular" foo function?
Is it possible to "point" that there's an implementation in the derived class?
Aucun commentaire:
Enregistrer un commentaire