
Untitled
By: a guest on
May 7th, 2012 | syntax:
None | size: 0.64 KB | hits: 10 | expires: Never
C , polymorphism vs. templatization of a function argument
template <typename T>
class A {T a;};
template <typename T>
class B: public A <T> {T b;};
template <typename Item>
struct TItems {typedef std::vector <Item> Type;};
template <typename Item>
class ModCont
{
private:
typename TItems <Item>::Type items;
};
template <typename T>
void test ( ModCont <A <T> > *it) {}
int main(int argc, char* argv[])
{
ModCont < A <double> > a_items;
ModCont < B <double> > b_items;
test (&a_items); //Works
test (&b_items); //Does not work
return 0;
}
template <typename Object>
void test ( ModCont <Object> *it) {}