Link to home
Start Free TrialLog in
Avatar of JohnSantaFe
JohnSantaFe

asked on

LNK2005 error redefinition

I'm getting a LNK2005 error due to redefinition of some functions.  The project has a main (test.cpp), two classes (myclass1.h, myclass1.cpp, myclass2.h, myclass2.cpp), and another header file (morefuncs.h) that is not a class but contains some functions.

I've used #pragma once in all header files.

The test.cpp #includes both header files for the classes.

If I include the header file for the additional functions, #include morefuncs.h into only one of the class header files, everything is fine.  However if I try to include morefuncs.h into the second class, I get the above linker redefinition error.  I'm assuming this is becasue the morefuncs is not a class but simply a header file that contains functions.

I'd rather not make morefuncs a class. Is there a way to include it into multiple other classes without a redefinition problem?
ASKER CERTIFIED SOLUTION
Avatar of AlexFM
AlexFM

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial