I am absolutely clueless as to why i keep getting this error. any suggestions would be greatly appreciated. (edit:) I rewrote the code in order to simplify my problem, and I finally got the program to run. i forcot to include "important business source.cpp" in the header. Thanks alot to everyone who lent an ear and their time.
//main.cpp
usingnamespace std;
#include <iostream>
#include <vector>
int Importantbusiness (int importantfiles)
{
return importantfiles;
}
int Importantbusiness (int importantfiles);
int main()
{
cout << "Important! We only have "<< Importantbusiness(4) << " important files left!"<< endl;
cin.get();
return 0;
}
I thought it might be because of a wrong ifndef and definition.. That's not the case however..
So until someone can find the real problem, I'd say you just put them together in one file..
Sorry, but I can't seem to solve it... Hope this much helps enough :)
@ LB: whaha yeah just noticed that :P Usually I don't use prototypes (unless it's a huge function), and I quickly made it in one file... But you're right, it should be before :P And adding the semicolon doesn't work (for me..)
But I actually don't see why you'd want to separate this in 3 files.. Headers are used so you can recycle code right? But I don't see how you'd want to recycle this piece of code.. So my suggestion is that you just write it in one file
ok, well so far I added the semicolon to the prototype in the header file, but now when i compile I get "undefined reference to `Importantbusiness(int)'" for line 9 of main.cpp.
@kaduk
Thanks for your help, but I'm currently trying to learn how one would use two source files for a single project, so putting all the functions in one file would kinda defeat the purpose.
Well, from your code, I see that it isdeclared, but not defined, as the error suggests. You define it in importantbusiness.cpp but that file never gets used anywhere! How should it be defined in Main.cpp if you defined it somewhere else that doesn't even get included? ;)