Advertisement

Wierd error with STL algorithm

Started by July 22, 2003 08:05 AM
3 comments, last by Scourage 21 years, 1 month ago
I am building an eliza type program and I was using the STL transform algorithm to convert all the characters in the input string (an STL::string) to uppercase for easy comparison. I had included the "using namespace std" at the beginning of my program but I recieved the error: No matching function call to transform(). When I comment out the "using namespace std" and specify all strings and algorithms with "std::" it works perfectly. The odd thing is that it compiled fine on my windows box (MS VC++ 6.0) without any problems. I read somewhere that the compiler might be mistaking the function template transform from algorithm.h with a function in iostream.h with the same name. Is there something that I'm leaving out? It's very frustrating to not be able to use namespace std. Cheers, Bob slackware 9.0 gcc 3.2 [edited by - scourage on July 22, 2003 1:31:00 PM]

[size="3"]Halfway down the trail to Hell...
Don''t wait VC++ 6 to be ISO C++ compliant. It is not, but only ANSI 96... So forget it for recent adds to C++.
Advertisement
oups...
but this is not Unix related post...
This is a common problem due to the existence of TWO overloaded toupper functions, one inherited from C (cctype) and one from C++ (locale).

An explanation and solution is available.

[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]

[edited by - Fruny on July 23, 2003 10:14:14 AM]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
quote: Original post by Scourage
...
I read somewhere that the compiler might be mistaking the function template transform from algorithm.h with a function in iostream.h with the same name.
...
Are you using header files with .h extensions? Those are non-standard, so naturally namespace std is not defined in them!
#include <iostream>#include <algorithm> using namespace std;... 

This topic is closed to new replies.

Advertisement