C
Christof Warlich
Hi,
consider this:
template<typename T> class X {
public:
void doSomething(T t);
};
int main(void) {
X<int> x;
x.doSomething(4);
return 0;
}
It compiles fine but the linker is missing the implementation of
doSomething().
Why may it ever make sense that the compilation of this works fine? The
compiler already _knows_ that it could not instantiate doSomething() for
type int since it has not seen the (template) implementation of
doSomething(). Thus, linking will _always_ fail. Or do I miss a way to
pass the doSomething() implementation for a specific type to the linker
from another object file?
Thanks for any help,
Christof
consider this:
template<typename T> class X {
public:
void doSomething(T t);
};
int main(void) {
X<int> x;
x.doSomething(4);
return 0;
}
It compiles fine but the linker is missing the implementation of
doSomething().
Why may it ever make sense that the compilation of this works fine? The
compiler already _knows_ that it could not instantiate doSomething() for
type int since it has not seen the (template) implementation of
doSomething(). Thus, linking will _always_ fail. Or do I miss a way to
pass the doSomething() implementation for a specific type to the linker
from another object file?
Thanks for any help,
Christof