|
-
April 23rd, 2010, 04:48 PM
#6
Re: template member functions in a non template class
 Originally Posted by Russco
With templates, you cant split the code into .h and .cpp files like you can with non-templates without export which virtually no compiler supports, or ever will, though comeau does.
When you include the .h in a file and try to use the templated function, the compiler tries to instantiate the template substituting the generic type(s) for specific type(s) but it cannot do that unless it can see the definition of the template.
This must be the issue. Thanks for this information. Frustrating since the instructor wants us to do it this way. Class header and class .cpp file. And I am using the templated function in another class .cpp file, for example I have a world class that uses the predator class. All different files of course.
ie. predator.h, predator.cpp, world.h, world.cpp
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
|