-
August 25th, 2009, 11:39 PM
#1
[RESOLVED] Template function and linking problem
hello,
i have a question regarding template function
i have a template function in .h file.
Code:
template <typename T>
int append(UINT8 *p, UINT16 type, T val)
{
.................
}
i am using it in two classes MyClass1.cpp MyClass2.cpp
when i included the "MyTemplate.h" in both the CPP file i get linking error. already defined !!
can some one please tell how to fix it
regards
deepak
-
August 26th, 2009, 01:06 AM
#2
Re: Template function and linking problem
Did you add a #pragma once at the beginning of the header file?
You can also make it a public, static method of a class, but you still need the header guards.
-
August 26th, 2009, 01:24 AM
#3
Re: Template function and linking problem
hello,
it is already there!! i even added the #define too.
i think the problem is that linker has got its definition and when it again encounters it.
it complains "Already defined in abc.obj" file
any other clue?
regards
deepak
-
August 26th, 2009, 01:41 AM
#4
Re: [RESOLVED] Template function and linking problem
solved!!
bad and silly problem!! thanks cilu!!
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
|