|
-
April 23rd, 2010, 03:55 PM
#1
template member functions in a non template class
I am working on an assignment and this problem has me puzzled. I am still working on working on template functions. Mostly within classes. I am seeking help on where my error is. Here is my code.
In my class header I have:
class predator
{
public:
template<typename t>
void hunt(t & prey);
// other stuff...
private:
// more stuff
}
In my definition I have this:
template <typename t>
void predator::hunt(t & prey)
{
// what I want it to do here
}
And to use the function I have something like:
predatorName.hunt(preyName);
Now when I compile (I have been using Dev c++) I get the following error:
Linker error: Undefined reference to 'void predator::hunt<predator>(predator&)'
Any hints on what I am doing wrong. Thanks very much in advance.
Kat
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|