This is the first time as a newcomer I have absolutely no idea what an error means. It says the following: "error: expected constructor, destructor, or type conversion before '&' token"
And it's happening for the following code:
1 2 3 4 5 6 7 8 9 10 11 12 13
#include <iostream>
using std::string;
using std::cout;
using std::cin;
using std::endl;
istream& taker(istream&); //line at which the error occurs.
int main() {
//let the compiler place the return statement
}
The error is triggered because of an error in the prototype for the function named taker.
Can somebody please tell me what I'm doing wrong ?
Yes you can, although it's often seen a a bad habit. Not sure anymore why, but Disch, i think, once explained me why :D
I think it has to do with some names you might choose for variables, that are actually in the std namespace. Like counter I think.
When you bring the entire std namespace into the global namespace (by usingnamespace std;) you bring a lot of names you won't use and which might cause name clashes. A common example is std::count(), but depending on the kind of application you're writing many more could arise.