- 1
I created separate header and source file idea.h and idea.cpp.I have re checked the code thrice but it is still returning error
main.cpp:error:undefined reference to `idea::idea() ' collect2.exe:error:ld returned 1exit status
2 odpowiedzi
+ 1
Is this inside a project? In codeblocks, I have encountered a problem that when you declare a header and its cpp file and compile it with the main cpp file of the project, the program is unable to link the cpp file and it gives errors like this.
Just check if doing :
#include"idea.cpp"
Resolved the error or not. If yes, you have the same error and will have to click "Add file to current project" to solve the issue. Sometimes the compiler treats the cpp file as some separate program, not linked with the project, even if they are in the same folder.