Re: A little misunderstanding with templates = a big hassle.


[ Follow Ups ] [ Post Followup ] [ CS2704 Web Discussion Board ] [ FAQ ]

Posted by Juan Romero Jr. on March 18, 2001 at 17:22:27:

In Reply to: A little misunderstanding with templates = a big hassle. posted by Matt Green on March 17, 2001 at 20:01:36:

: I started drafting my program today, and began messing around with templates and the Array class. I think I remember noticing in class that the slides had both the declaration and the implementation of classes in the same file and it seemed strange. But I went ahead and split it into the cpp file and the h file, as we've been taught. I kept getting linker errors for every function that was used. I check the syntax of the templated member functions and the class against the notes and Stroustrup's documentation.

: Well 2 hours later I was looking on Deja.com's usenet archives and it seems that you have to consolidate the files, since they perform akin to macros. Hopefully this note will save people some time.

well if I remember correctly McQuain said in class that Template code doesnt compile until you give a type for its parameter, and since code in a cpp file is going to get compiled, you need to put template code in the header file.


Follow Ups:



Post a Followup

Name:
E-Mail:

Subject:

Comments:

Optional Link URL:
Link Title:
Optional Image URL:


[ Follow Ups ] [ Post Followup ] [ CS2704 Web Discussion Board ] [ FAQ ]