Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using class templates in .h file

Status
Not open for further replies.

amanyasin

Technical User
Feb 7, 2003
28
Hi

Dear i want to use class template in header file .h , i also want to keep my code separat in .cpp file. can you guide me how it is possible?
===============
.h file

template<typename t>
class myclass
{
void myfunction(t);
};

==============

.cpp file
template<typename t>
void myclass<t>::myfuntion(t)
{
..
..

}
===========

my main program

..
..
myclass<double> test;

test.myfunction( double);

...

==============

for classess or namspacess

thanks in advance
 
You can't do that in C++ unfortunately. All the template code has to be in the header file (or #included by the header file).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top