Solved

Template Classes

Posted on 2004-04-28
2
344 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 500 total points
ID: 10938878
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
ID: 10939133
I have suspected something like this. Thanks for your great answer.
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

636 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