Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#Actuallukesmith123

Posted 15 March 2012 - 07:01 AM

Hi,

I made a template class like this:

template<class identifier>
class myclass
{
public:
   void function();
};

and I want to define the function in a cpp file but I cant figure out how to do this. I tried this:

template<class identifier>
myclass::function()
{
   //---
}

but I get the error - use of template requires template argument list.

Is there any way I can define the functions for the class in a cpp file or would I just need to do it in the header?

thanks,

#1lukesmith123

Posted 15 March 2012 - 07:00 AM

Hi,

I made a template class like this:

template<class identifier>
class myclass
{
	 void function();
};

and I want to define the function in a cpp file but I cant figure out how to do this. I tried this:

template<class identifier>
myclass::function()
{
	 //---
}

but I get the error - use of template requires template argument list.

Is there any way I can define the functions for the class in a cpp file or would I just need to do it in the header?

thanks,

PARTNERS