I'm having difficulty understanding these error messages and why my code doesn't work
Error Messages:Code:/Purpose: Demonstrates pass by refrence using pointers and refrences #ifdef HAVE_CONFIG_H #include <config.h> #endif #include <iostream> #include <string> #include <algorithm> #include <cctype> using namespace std; void name_to_upper(string* tempName){ transform ((*tempName).begin(), (*tempName).end(), (*tempName).begin(), toupper); } void name_to_lower(string& tempName){ transform (tempName.begin(), tempName.end(), tempName.begin(),tolower); } int main(int argc, char *argv[]) { string name; cout << "Enter your name then I will display it in all caps, then in all lower letters: "; cin >> name; cout << "Original Name -> " << name << endl; name_to_upper(&name); cout << "In caps ->" << name << endl; name_to_lower(name); cout << "All lower -> "<< name << endl; return EXIT_SUCCESS; }
/home/ripspinner/passbyrefrence/src/passbyrefrence.cpp: In function ‘void name_to_upper(std::string*)’:
/home/ripspinner/passbyrefrence/src/passbyrefrence.cpp:34: error: no matching function for call to ‘transform(__gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, <unresolved overloaded function type>)’
/home/ripspinner/passbyrefrence/src/passbyrefrence.cpp: In function ‘void name_to_lower(std::string&)’:
/home/ripspinner/passbyrefrence/src/passbyrefrence.cpp:38: error: no matching function for call to ‘transform(__gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::
Please help![]()



LinkBack URL
About LinkBacks



