first I know this is a terrible thing to do as it may require large amounts of memory copying… but it needs to be done because of specifications I have been given.
Anyway, I am trying to pass a string by reference and a vector by value as it will be edited then destroyed and then the original will be used again.
Here is the function prototype
int print (const string& findme,const string& command,const string& command2,const string& command3, int n, vector<string> list)
and here is my call, all variables are of the correct type.
print (special,command,command2,command3,n,temp);
Everything compiles and runs when I do not attempt to call the function… but when I do I get this error:
a2p1.cc: In function âint main(int, char**)â:
a2p1.cc:85: error: no match for call to â(std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >) (std::string&, std::string&, std::string&, std::string&, int&, std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&)â
SO I was wondering… how should I be passing these strings and the vector to the function the strings can be passed by reference but I need a copy of the vector, any syntax help would be very helpful! Thanks!
Here are the variables
int n;
string command = "rr";
string command3 = "null";
string command2 = "f";
string japan;
string special;
special = "fnord";
string textFileName;
vector<string> list;
vector<string> print;
And here is the call to the function, on line 83:
while (cin >> inputtemp)
{
...
if ((inputtemp == "p")){
print (special,command,command2,command3,n,list);
}// If
}// While
You have both a function and a variable named
print.You’re not actually calling the
printfunction.Rename the variable.
(Your function prototype is correct. It will do what you describe)
Look again at your error to see this. (I removed the templates to make it simpler)