I'm having a problem compiling a multiple-part project. I thought I had included the correct
#ifndef/#define statements and included header files correctly, but apparently not. When attempting to compile this error came up:
[23:18]andrew final_project$:g++ driver2.cpp fish.cpp bay.cpp
ld: duplicate symbol Fish::Fish() in /var/folders/cc/cc+as-5yHSqg0Jcr+X2+uk+++TI/-Tmp-//ccqNXrPE.o
and /var/folders/cc/cc+as-5yHSqg0Jcr+X2+uk+++TI/-Tmp-//cc5dOIm5.o for
collect2: ld returned 1 exit status
I can include more information if necessary, but my two header files (
bay.h) are bookended with.
my two implementation files are
#include "bay.h" #include "fish.h"
My driver program driver2.cpp:
#include "fish.cpp" #include "bay.cpp"
I assume the problem lies in the fact that bay.cpp includes both fish.h and bay.h, but when I don't include fish.h the "bay" (a grid of fish) is undefined. I would guess the problem isn't too hard, but I can't seem to find a solution.
--Thanks in advance,
Don't include the .cpp files in