• Advertisement

Archived

This topic is now archived and is closed to further replies.

Abstract Template

This topic is 5980 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is their such a thing? Basically an abstract class (with =0 on a couple methods) and its a template. Is it possible?

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Yes. Dunno whether it''s ANSI/ISO C++ or not, but I did it with a couple of compilers (never tried with MSVC though, as its template support isn''t great).

Share this post


Link to post
Share on other sites
how about this then..... an abract class, thats been instantiated a couple times.....

ex
abstract (non template) class CShape with child (template) class CTriangle....

Share this post


Link to post
Share on other sites
I am not exactly sure what you''re getting at, but I''ll say this: I don''t think that, given that Derived<T> derives from Base<T>, I don''t think that Base<int>* can point to Derived<char>, for example. But I could be wrong.

Share this post


Link to post
Share on other sites
Sure, I use it:

      
template <typename TObserver>
class IObservable
{
public:
virtual HRESULT AddObserver(TObserver* pObserver)=0;
virtual HRESULT RemoveObserver(TObserver* pObserver)=0;
};

template <typename TObserver>
class CUniObservable : public IObservable<TObserver>
{
//...

}



Magmai Kai Holmlor
- Not For Rent

I even mutliply inherit from it:
  
class CGameEngine : public CObservable<IPerformanceObserver>,
public CObservable<IUIObserver>,
protected INetworkClientObserver,
protected INetworkServerObserver
{
//...

};



Edited by - Magmai Kai Holmlor on September 6, 2001 12:45:18 AM

Share this post


Link to post
Share on other sites

  • Advertisement