Override template function with polymorphic one
Hi there!
If I have
1 2 3 4 5
|
template<class T>
TalkyBuffer& operator<<(T const &object) { // Template
...
}
TalkyBuffer& operator<<(TalkySerialisable const &object); // Override
|
and a class
1 2
|
class A : public TalkySerialisable {
...}
|
Then if I perform
1 2 3
|
TalkyBuffer b;
A test;
b << test;
|
Then gcc is calling the Template function rather than the Override function
However if I specifically define an override
|
TalkyBuffer& operator<<(A const &object); // Override without polymorphism
|
Then gcc picks that one.
Is there a practical way to override a templated function with an abstract class?
I read this but it doesn't shed light onto what happens when you throw polymorphism into the mix:
http://www.gotw.ca/publications/mill17.htm
Thanks for reading!
elliot
Last edited on
Topic archived. No new replies allowed.