|
-
October 20th, 2010, 07:17 PM
#1
about template and multiple files projects.
Hello,
C++ requires that the declaration and definition of a template must be in the same file.
Suppose we have the following scenario:
//tc.h
template<T>
class{
};
//file1.cc
#include"tc.h"
class<int> obj1;
bla bla .....
//file2.cc
#include"tc.h"
class<int> obj2;
bla bla ....
when file1.cc and file2.cc are complied separately, each of them will contain a realization of a template for int. I wonder how the linker handle this situation. The linker will leave two realizations in the final code(which will increase the size of the final code) or it will only keep one realization(which seems more complicated)
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
|