Click here to Skip to main content
15,901,205 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionTemplate function compilation and linking question. Pin
Maximilien22-May-07 4:43
Maximilien22-May-07 4:43 
AnswerRe: Template function compilation and linking question. Pin
Nelek22-May-07 5:18
protectorNelek22-May-07 5:18 
GeneralRe: Template function compilation and linking question. Pin
jhwurmbach22-May-07 5:30
jhwurmbach22-May-07 5:30 
GeneralRe: Template function compilation and linking question. Pin
Arman S.22-May-07 5:33
Arman S.22-May-07 5:33 
AnswerRe: Template function compilation and linking question. Pin
jhwurmbach22-May-07 5:34
jhwurmbach22-May-07 5:34 
AnswerRe: Template function compilation and linking question. Pin
Arman S.22-May-07 5:43
Arman S.22-May-07 5:43 
AnswerRe: Template function compilation and linking question. Pin
David Crow22-May-07 6:19
David Crow22-May-07 6:19 
AnswerRe: Template function compilation and linking question. Pin
cp987622-May-07 14:47
cp987622-May-07 14:47 
This reminds me of the sorts of errors I got on older compilers (when I was learning about templates) if the definition was not in the header. I don't know what the situation is with newer compilers as I always put the code in the header.

The reason was that it was necessary for the compiler to have the function definition when it encountered a specific instance of the templated function in order to create the code. To create the code for a templated function definition the compiler needs both the function definition and an instance that specifies what template parameters are required.

So for example, when the compiler encountered DoSomething<double> that would trigger it to create the actual 'double' version of the code. This would work if the definition was available to the compiler at the time; either in the header or in the actual source file that the 'double' version was used in. If it couldn't find the definition no object code was created and unless the code for DoSomething<double> was created elsewhere, a linker error would result.




Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
AnswerRe: Template function compilation and linking question. Pin
cmk22-May-07 18:07
cmk22-May-07 18:07 
AnswerRe: Template function compilation and linking question. Pin
Michael Dunn22-May-07 20:44
sitebuilderMichael Dunn22-May-07 20:44 
GeneralRe: Template function compilation and linking question. Pin
Maximilien23-May-07 13:17
Maximilien23-May-07 13:17 
QuestionMultiple string resources Pin
rrrado22-May-07 4:42
rrrado22-May-07 4:42 
AnswerRe: Multiple string resources Pin
Sameerkumar Namdeo23-May-07 0:51
Sameerkumar Namdeo23-May-07 0:51 
GeneralRe: Multiple string resources Pin
rrrado23-May-07 21:50
rrrado23-May-07 21:50 
QuestionProblems in lock hotkeys like Alt+Tab,Alt+Esc,Ctrl+Alt+Del etc Pin
abhiakude22-May-07 4:18
abhiakude22-May-07 4:18 
QuestionRe: Problems in lock hotkeys like Alt+Tab,Alt+Esc,Ctrl+Alt+Del etc Pin
David Crow22-May-07 6:30
David Crow22-May-07 6:30 
AnswerRe: Problems in lock hotkeys like Alt+Tab,Alt+Esc,Ctrl+Alt+Del etc Pin
abhiakude22-May-07 19:20
abhiakude22-May-07 19:20 
GeneralRe: Problems in lock hotkeys like Alt+Tab,Alt+Esc,Ctrl+Alt+Del etc Pin
David Crow23-May-07 2:53
David Crow23-May-07 2:53 
GeneralRe: Problems in lock hotkeys like Alt+Tab,Alt+Esc,Ctrl+Alt+Del etc Pin
abhiakude24-May-07 21:13
abhiakude24-May-07 21:13 
GeneralRe: Problems in lock hotkeys like Alt+Tab,Alt+Esc,Ctrl+Alt+Del etc Pin
David Crow25-May-07 2:38
David Crow25-May-07 2:38 
QuestionReference Pin
Kiran Pinjala22-May-07 4:18
Kiran Pinjala22-May-07 4:18 
AnswerRe: Reference Pin
Manoj Kumar Rai22-May-07 4:38
professionalManoj Kumar Rai22-May-07 4:38 
GeneralRe: Reference Pin
Arman S.22-May-07 5:13
Arman S.22-May-07 5:13 
AnswerRe: Reference Pin
Arman S.22-May-07 5:18
Arman S.22-May-07 5:18 
AnswerRe: Reference Pin
jhwurmbach22-May-07 5:43
jhwurmbach22-May-07 5:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.