Quantcast
Viewing latest article 14
Browse Latest Browse All 50

Answer by David Z for Specify template argument by subclassing

When you write Parent<char>, the compiler effectively generates a class definition as if you had substituted char into the template text. That is, behind the scenes it's as if the parent class of CharVersion is the following template instantiation:

class Parent_char {public:    virtual char someFunction(const char& data);};

You can write your subclass just as if you were extending that class. (Of course, the name of the generated template instantiation is not Parent_char, but that's unlikely to matter.)


Viewing latest article 14
Browse Latest Browse All 50

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>