templates and inheritance

Started by
2 comments, last by DanG 21 years, 10 months ago
Is it possible for a nontemplate class to inherit from a templated base with the type specified? What i mean is, is this syntax legal?
  
template <class T>
class BASE
{
   T * ptr;
};

class CHILD : public BASE<CHILD>
{
  // more stuff

}

// implementation

ptr = new CHILD;
//

  
will that type of setup work? [edit: added source tags] [edited by - Magmai Kai Holmlor on June 7, 2002 1:06:57 AM]
Ambassador: Mr. Bush are you stoned or just really, REALLY dumb?Pres. Bush - I assure you I am not stoned.
Advertisement
Did you try?

Hint: this is the way ATL works.
---visit #directxdev on afternet <- not just for directx, despite the name

  template <typename T>class A{public:	A(T t) : var(t) {}private:	T var;};class B : public A<int>{public:	B(T t) : A(t) {}};  


Something like that? Yes.
The only wrong with your syntax is the all capital names (MACROS_ONLY).
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara

This topic is closed to new replies.

Advertisement