User Defined Class as a Template Parameter

Posted by isurulucky on Stack Overflow See other posts from Stack Overflow or by isurulucky
Published on 2010-05-20T04:42:40Z Indexed on 2010/05/20 4:50 UTC
Read the original article Hit count: 194

Filed under:
|
|

Hi,

I' m implementing a custom STL map. I need to make sure that any data type (basic or user defined) key will work with it. I declared the Map class as a template which has two parameters for the key and the value. My question is if I need to use a string as the key type, how can I overload the < and > operators for string type keys only?? In template specialization we have to specialize the whole class with the type we need as I understand it. Is there any way I can do this in a better way?? What if I add a separate Key class and use it as the template type for Key?

Thank You!!

© Stack Overflow or respective owner

Related posts about c++

Related posts about stlmap