Victor Bazarov escreveu:
Paulo da Silva wrote:
>Hi!
Why doesn't this work?
See the compiler output below.
>
What clue tells you it doesn't work? An error message? Could you
be so kind as to supply the error message (or is it just too much
to ask)?
No.
>
>If I change the name of the vector toLower for
ex. to toLowerV it works! (GCC)
Thanks.
Paulo
.....
Reposting a complete desierable compilable part:
pt2.h
#include <string>
#include <vector>
using namespace std;
// Auxiliary functions
class Aux
{ private:
public:
static string &toLower(string &s);
static void toLower(vector<string&vs); // Changing the name works!
};
pt2.cpp
#include "pt2.h"
string &Aux::toLower(string &s)
{ transform(s.begin(),s.end(),s.begin(),::tolower);
return s;
}
void Aux::toLower(vector<string&vs) // Changing the name works!
{ transform(vs.begin(),vs.end(),vs.begin(),Aux::toLo wer);
}
int main()
{
return 0;
}
This code doesn't compile (because 'string' or 'vector' are undefined).
:-)
No!. This is part of a bigger program. The needed headers are there.
I think the compiler cannot determine which "toLower" to use in the 2nd.
transform.
Is there a way I can force it to use the first?
__________________________________________________ ___
pt2.cpp: In static member function 'static void
Aux::toLower(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 &)':
pt2.cpp:9: error: no matching function for call to
'transform(__gnu_cxx::__normal_iterator<std::basic _string<char,
std::char_traits<char>, std::allocator<char*,
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 >,
__gnu_cxx::__normal_iterator<std::basic_string<cha r,
std::char_traits<char>, std::allocator<char*,
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 >,
__gnu_cxx::__normal_iterator<std::basic_string<cha r,
std::char_traits<char>, std::allocator<char*,
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 >, <unresolved
overloaded function type>)'