I'm trying to see how having several header and .cpp files work. But I'm encountering a problem: "In file included from print.cpp"
It's a very short project, but since there's multiple files, I zipped it up. Thx for the help ppl! :D
Printable View
I'm trying to see how having several header and .cpp files work. But I'm encountering a problem: "In file included from print.cpp"
It's a very short project, but since there's multiple files, I zipped it up. Thx for the help ppl! :D
You haven't referenced any namespaces.
You haven't #include <iostream> in main.cpp
This:
printthis(YES!)
should be:
printthis("YES!")
.. and printthis() returns void, so you can't use it in the middle of a cout statement. Split it up like so:
Code:cout << "Try printthis(): ";
printthis("YES!");
cout << "Try printthat(): ";
printthat("YES!");
Okay...those were stupid errors, and i just fixed them. However, the same errors are still there. The first one is (and probably da most important one):
print.cpp line 3 in file included from print.cpp
You still haven't referenced any namespaces:
My guess is you've forgotten that elsewhere as wellCode:#ifndef PRINT_H
#define PRINT_H
#include <string>
void print(const std::string& s);
#endif
I didn't want to use any namespaces, and then realize that I have to put std:: infront of string and otherstuff as well....><
All of the old problems are fixed now, but there's 2 new ones "linker problems: print(const std::string& s) undefined"
:(
You function implementation for print() is wrong:
void print(const std::string s)
You forgot the &
Thx, I got it now.