How to get resolve with function redefinition error
| Mon, 2004-02-02 13:42 | |
|
|
I am getting sick with this error, function Redefinition !!! .I am building a log file, So that i can keep track of my program memroy allocation and deallocation, to get rid of memory leaks.For that i have build a function template in a Namespace. What i am doing is that , i will pass Object to this function, this object could be of any type, and getting information about that Object. // MemTrack.h #ifndef MEMTRACK_H #define MEMTRACK_H #include <f32file.h> namespace MemTracker { void LogInit(const char* logName = NULL) { //Doing Something with logName } template<class T> void MemLog( T* mVar ) { // Doing something with mVar } }; #endif Now when i include this template function file in one file it is fine // Myclass.cpp #include "MemTrack.h" MyClass::MyClass() { MemTracker::MemLog(this); //Working fine , no error } But when i include this MemTrack.h file in another file(s) it give me error given below error LNK2005: "void __cdecl MemTracker::LogInit(char const *)" (?LogInit@MemTracker@@YAXPBD@Z) already defined in SEARCHFILECONTAINER.obj PLease help me , and tell me how could i able to get access this function in multiple files : ...... Thanks in advance with best regards chetan ---- |






with this error, function Redefinition !!! .
: .
Forum posts: 239
Have u resolved your problem.
If yes ,then could you tell me how..
BR
---------------
Bhatt Kavita
Forum posts: 101
Forum posts: 276
So move your function definition to your header file and your problem will be solved...
Dennis
Today is a gift by GOD, that's why it is called the present.