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!
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!
An Unofficial Cristiano Ronaldo Website : Ronaldo 7
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!");
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
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
An Unofficial Cristiano Ronaldo Website : Ronaldo 7
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
"Think not but that I know these things; or think
I know them not: not therefore am I short
Of knowing what I ought."
-John Milton, Paradise Regained (1671)
"Work hard and it might happen."
-XSquared
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"
An Unofficial Cristiano Ronaldo Website : Ronaldo 7
You function implementation for print() is wrong:
void print(const std::string s)
You forgot the &
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
Thx, I got it now.
An Unofficial Cristiano Ronaldo Website : Ronaldo 7