I get an error when I compile the following code:
#include <algorithm>
#include <cctype>
#include <iostream>
#include <string>
using namespace std;
string&
lc(string& s)
{
transform(s.beg in(), s.end(), s.begin(), tolower);
return s;
}
int
main()
{
string name = "DAVID";
cout << name << " " << lc(name) << endl;
return 0;
}
; g++ lc.cc
lc.cc: In function `std::string& lc(std::string& )':
lc.cc:11: error: no matching function for call to `transform(
__gnu_cxx::__no rmal_iterator<c har*, std::basic_stri ng<char,
std::char_trait s<char>, std::allocator< char> > >,
__gnu_cxx::__no rmal_iterator<c har*, std::basic_stri ng<char,
std::char_trait s<char>, std::allocator< char> > >,
__gnu_cxx::__no rmal_iterator<c har*, std::basic_stri ng<char,
std::char_trait s<char>, std::allocator< char> > >, <unknown type>)'
If I do not include iostream, or if I use a different function
(e.g., int id(int i){return i;}), I do not get any errors. Am I doing
something wrong?
/david
--
Andre, a simple peasant, had only one thing on his mind as he crept
along the East wall: 'Andre, creep... Andre, creep... Andre, creep.'
-- unknown
#include <algorithm>
#include <cctype>
#include <iostream>
#include <string>
using namespace std;
string&
lc(string& s)
{
transform(s.beg in(), s.end(), s.begin(), tolower);
return s;
}
int
main()
{
string name = "DAVID";
cout << name << " " << lc(name) << endl;
return 0;
}
; g++ lc.cc
lc.cc: In function `std::string& lc(std::string& )':
lc.cc:11: error: no matching function for call to `transform(
__gnu_cxx::__no rmal_iterator<c har*, std::basic_stri ng<char,
std::char_trait s<char>, std::allocator< char> > >,
__gnu_cxx::__no rmal_iterator<c har*, std::basic_stri ng<char,
std::char_trait s<char>, std::allocator< char> > >,
__gnu_cxx::__no rmal_iterator<c har*, std::basic_stri ng<char,
std::char_trait s<char>, std::allocator< char> > >, <unknown type>)'
If I do not include iostream, or if I use a different function
(e.g., int id(int i){return i;}), I do not get any errors. Am I doing
something wrong?
/david
--
Andre, a simple peasant, had only one thing on his mind as he crept
along the East wall: 'Andre, creep... Andre, creep... Andre, creep.'
-- unknown
Comment