[Dev-C++] Overriding Template functions
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
From: ravishankar k. <rav...@ya...> - 2009-03-18 18:32:53
|
Hi guys, Can we override template functions? I have a template function like template <typename IntegerType> bool decodeField (IntegerType& dest, int fieldId) { // Get the field offset, do some processing and return the result in 'dest' template variable. } The above function handles different integer types like uint_8, uint_16, uint_32, uint_64, int_8, int_16, int_32, int_64. I want to make the above function virtual and would like to override this function in the derived class with a slightly different functionality. As far I can see in google, both 'virtual' and template function cannot exist together. The recommendation is to provide a another virtual function and call that function from the template function. But my worry is that how do we pass the template argument to the other virtual function. Any idea on how to achieve this functionality? Regards, Ravi. Add more friends to your messenger and enjoy! Go to http://messenger.yahoo.com/invite/ |