![]() |
undefined reference Error!
Would someone help me understand why I keep getting the error:
"In function main: [linker error] undefined reference to readBook(BookData)" I have spend hours trying to fix it, but no luck :/ Thanks in advance main.cpp : Code:
#include <iostream>BookData.cpp : Code:
#include <string>Code:
#ifndef BOOKDATA_H |
Re: undefined reference Error!
I get no error (although I had to add "using namespace std;" to BookData.h) with Visual Studio 2010. What compiler and OS are you using (including version numbers)?
Also I would suggest not defining "class BookData" twice; just define it once in BookData.h, then #include BookData.h wherever you need it. Otherwise You will need to ensure both copies of class BookData remain consistent. |
Re: undefined reference Error!
Yes. you are right. I was using the Dev C++, and had no idea I need to put them in a project to be able to run it! Thanks for the advice. I added the namespace, and erased the extra parts and it worked.
|
| All times are GMT +5.5. The time now is 09:37. |