Solved

Template Classes

Posted on 2004-04-28
2
343 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

738 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