Solved

Template Classes

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Parse a URL key value 4 181
Debug Error using Visual C++ 6.0 5 141
L prefix in C++ 8 109
Software tool to depict the structure of a Visual Studio solution/project 6 98
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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

776 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