Click here to Skip to main content
16,004,564 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
==Hi All,

I want to create a class template, which is able to accept a user defined data type as a parameter.

for eg:

template <class t="">
class MyClass
{
};

now i want to create a another class,
ie

class sample
{
};
and MyClass should able to accept the sample class as a input parameter.



Thanks in advance
Posted
Updated 13-Dec-13 17:04pm
v3
Comments
Philippe Mori 14-Dec-13 8:23am    
Put your code in code block please and add missing < and >.

1 solution

The template code needs to "understand" what the sample class is... you will need to #include the sample class header in the file containing MyClass (and before the 'template class MyClass' statement).

You could also add the MyClass definition at the end of the header file for sample (ie. after sample is defined).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900