Solved

Template Classes

Posted on 2004-04-28
2
337 Views
Last Modified: 2011-09-20
Is it possible to have a generic object of a template class?

Example:

template <typename t> class CEvent
{ ...
};

class CEventlist
{ CEvent *event;
 ...
}

event in CEventlist shouldn't use a template parameter and CEventlist shouldn't be templated too.
0
Comment
Question by:mbruenjes
2 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 500 total points
Comment Utility
Absolutely impossible. Template is not real class, actual class is created by compiler only when template is instantiated. For example, CEvent is not class, but CEvent<int> is class. CEvent* gives compiler error, and CEvent<int>* is OK.
You need to think in another direction. For example, template class may be derived from some non-template class (interface), and CEventlist contains pointers to base classes.
0
 

Author Comment

by:mbruenjes
Comment Utility
I have suspected something like this. Thanks for your great answer.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
In Easy String Encryption Using CryptoAPI in C++ (http://www.experts-exchange.com/viewArticle.jsp?aid=1193) I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now