.template?

Oct 5, 2012 at 4:00am
Im implementing a template class. I created a tem.template class to implement it im using Microsoft visual c++ but all my code looks black no colors like when i write in .h or .cpp is it normal? Or is not recognizing the .template?
Last edited on Oct 5, 2012 at 4:00am
Oct 5, 2012 at 4:17am
.template is not a standard extension, so it's just not applying any syntax coloring. Why not just use the .h extension?
Oct 5, 2012 at 4:21am
because i already have my class .h
so the implementations should be .cpp


but because i am using template class I have to create a class .h
and the implementation should be .template that is according the book
Oct 5, 2012 at 4:34am
.h is the extension for header files. Classes are data structures, not files

If your book says that template classes must be implemented in .template files I suggest you to burn the book and beat up the writer
Last edited on Oct 5, 2012 at 4:34am
Oct 5, 2012 at 4:39am
jajaja ok I might be wrong, Ill read it again thanks
Oct 5, 2012 at 4:51am
Ok, now for a serious post, I think I understand that you already have an header where you declared you template class
All you have to do to implement that class is creating a .cpp file, include the header where the class is declared, and implement the methods of the class
Oct 5, 2012 at 5:48am
I'm guessing that you're trying something like this:

1
2
class tem {};
tem.template();


A template class should look like this:
1
2
3
4
5
6
template <class T> 
class tem
{
};

tem<int> MyObject;


Last edited on Oct 5, 2012 at 5:48am
Oct 5, 2012 at 6:30am
thank you
Topic archived. No new replies allowed.