Code::Blocks Forums
User forums => Help => Topic started by: davereid20 on January 19, 2006, 06:31:58 am
-
So...asking everyone out there right now...
How do you implement your files when you use templated classes (say a Queue/Stack ADT) and compile with gcc? I like the idea of definition and implementation in separate files. Do you put all the defenitions and implementations in the .h file and don't bother with a .cpp file? Do you put your definitions in a .h file and the implementation in a .cpp file and include both files? I can't really find a reliable source with a standard way to use templated classes with recent gcc. What do more experienced users recommend?
-
Template definitions need to be placed in the header or you'll be forced to manually instantiate the template for all the types you will ever use in the template when you compile the implementation file.
-
Since g++ hasn't support for exported templates I just put all the code in the header file.
-
Since g++ hasn't support for exported templates I just put all the code in the header file.
Yes, that is what I do too. I do not really like it, but better than including a cpp file :).
Michael