I'm writing my first template class for an assignment, and must admit I'm really having to feel this out as I go (it would help if we were given notes on how to do it...)
Anyway,I'm getting bizarre errors when trying to compile my code. I have a header/definition file and a driver file, and I'm not entirely sure how one should go about declaring a object from the template class. This is my big need right now, though I'm getting other bizarre errors, for some reason.
Here's the code. First, the header/definition file:
And finally, here are the errors I'm getting, both related to the driver file:
testsortdriver.cpp(16): error C2143: syntax error : missing ';' before 'template'
testsortdriver.cpp(16): error C2953: 'Sorter' : class template has already been defined
So, any advice is appreciated. Also, if you can think of a decent resource for making template classes, that wouldn't be too shabby either. It'd be a huge help :)
Thanks, for the suggestion, but I have tried removing line 9 (originally I didn't have it in). I do get other errors without this line, will have to post those shortly.
What's also weirding me out is that error saying it expects a semicolon before line 9 (the template declaration). I don't know why it wants one, but if I put one on the end of the #include line above it, I (rightly) get a preprocessing directive error. If I instead put the semicolon on the EMPTY line between the #include and the template declaration, it stops complaining! I have no idea what that's about.
EDIT: Just ran the code again, and the most consistent errors I get are that the class template has already been defined (re: the .hpp file), and that the class has no constructor (re: the .cpp driver file).