there is only one definition of MyFourierClass::forward_fft in my project. When I declare MyFourierClass::forward_fft as public, I get this error, otherwise there is no error.
Error Message:
1>my_fourier.obj : error LNK2005: "public: void __cdecl MyFourierClass::forward_fft(int)" (?forward_fft@MyFourierClass@@QEAAXH@Z) already defined in main.obj
1>CGPProject\x64\Debug\CGPProject.exe : fatal error LNK1169: one or more multiply defined symbols found
my_fourier.cpp:
#ifndef MY_FOURIER
#define MY_FOURIER
class MyFourierClass {
double** dataset = 0;
//public: // <-- un-commenting this line causes the linker error.
void forward_fft(int);
};
void MyFourierClass::forward_fft(int bins) {
bins = bins + 1;
};
#endif
Main:
#ifndef MY_MAIN
#define MY_MAIN
#include "my_fourier.cpp"
int main() {
int i = 0;
}
#endif
is there a standard method for debugging linker errors? I thought there might be a definition in another file, so I've delete all other files in my project. There is now only main.cpp and my_fourier.cpp. I'm using Visual Studio 2019.
Thanks in advance.