P
pocmatos
Hi all,
I have an abstract class acting as interface to a given class of
objects. And mostly everywhere around my program I'm passing things
like: vector<int>, list<unsigned long>, list<myclass*>, just to access
the elements it contains. Today I decided to refactor and to try
templates.
So I have abstract class A with function foo which receives
list<myclass*>. And now I want it to receive an Input Iterator
(following the idea behind <algorithm>). So I try this:
template<class InputIterator>
virtual void foo(InputIterator first, InputIterator last) = 0;
Then I have B inheriting from A, defining the function foo. However it
seems the compiler doesn't like template<...> virtual... I also tried
the other way around (virtual template...) but it is of no use.
Any ideas on how to do this is _extremely_ welcome.
Oh, by the way... "Effective C++" book is on its way... Heard great
things about it. Hope its true!
Cheers,
Paulo Matos
I have an abstract class acting as interface to a given class of
objects. And mostly everywhere around my program I'm passing things
like: vector<int>, list<unsigned long>, list<myclass*>, just to access
the elements it contains. Today I decided to refactor and to try
templates.
So I have abstract class A with function foo which receives
list<myclass*>. And now I want it to receive an Input Iterator
(following the idea behind <algorithm>). So I try this:
template<class InputIterator>
virtual void foo(InputIterator first, InputIterator last) = 0;
Then I have B inheriting from A, defining the function foo. However it
seems the compiler doesn't like template<...> virtual... I also tried
the other way around (virtual template...) but it is of no use.
Any ideas on how to do this is _extremely_ welcome.
Oh, by the way... "Effective C++" book is on its way... Heard great
things about it. Hope its true!
Cheers,
Paulo Matos