Board index » cppbuilder » Help... I don't understand one compile error...

Help... I don't understand one compile error...


2004-02-28 05:17:24 AM
cppbuilder69
Hi,
I need to adapt a project developped with DEV-C++ with gnu g++, into
Borland C++ builder 5.0 but I'm in trouble with one error...
The follow code...
#include <string>
#include <algorithm>
#include <iostream>
//--------------------------------------------------------------------------
-
#pragma hdrstop
//--------------------------------------------------------------------------
-
#pragma argsused
int main(int argc, char* argv[])
{
std::string str = "io non so cosa fare";
str.erase(std::remove(str.begin(), str.end(), ' '), str.end());
std::cout << str << std::endl;
system("pause");
return 0;
}
//--------------------------------------------------------------------------
-
works correctelly with GNU g++ 3.2 and reply with:
iononsocosafare
Premere un tasto per continuare...
... but it doesn't work with Borland c++ Builder 5.0
I recive the follow errors ...
[C++ Error] Unit1.cpp(15): E2227 Extra parameter in call to
std::remove(const char *)
[C++ Error] Unit1.cpp(15): E2285 Could not find a match for
'_STL::string::erase(int,char *)'
Please help me!
Thanks a lot,
Checco
--
Using M2, Opera's revolutionary e-mail client: www.opera.com/m2/
 
 

Re:Help... I don't understand one compile error...

Wrong newsgroup. You have posted a C++ Builder question here in the
newsgroup for the old Borland C++ compiler. Look for newsgroups with the
word 'cppbuilder' in their name.
. Ed
 

Re:Help... I don't understand one compile error...

At 23:25:40, 27.02.2004, Ed Mulroy [TeamB] wrote:
Quote
Wrong newsgroup. You have posted a C++ Builder question here in the
newsgroup for the old Borland C++ compiler. Look for newsgroups with
the word 'cppbuilder' in their name.

. Ed
Actually, he chose to cross-post. Follouwp set to cppbuilder.language.cpp
--
Rudy Velthuis (TeamB)
"I shall not waste my days in trying to prolong them."
- Ian L. Fleming (1908-1964)
 

{smallsort}

Re:Help... I don't understand one compile error...

Sounds like the compiler may be getting confused over the use of 'std::'.
Could you declare 'using namespace std', at the top?
 

Re:Help... I don't understand one compile error...

It looks like the version of remove it's trying to match is the one from
stdio.h, which deletes a file. There's clearly more to your code than
you are showing. It would help if you posted a cut-down version of your
program which shows the the problem. Post it *exactly* as you compile
it. You might even find the cause of the problem while going through
this exercise.
Quote
[C++ Error] Unit1.cpp(15): E2227 Extra parameter in call to
std::remove(const char *)
 

Re:Help... I don't understand one compile error...

Quote
std::string str = "io non so cosa fare";
str.erase(std::remove(str.begin(), str.end(), ' '), str.end());
What are you trying to do with that?
std::remove is a standard C/C++ library function that takes a const
char* string and deletes a file. It is the equivalent of unlink. It
is not an algorithm. That line of code will not work with any C++
compiler.
You have posted your C++ Builder question here in the newsgroups for
the old Borland C++ compiler. C++ Builder newsgroups have the word
'cppbuilder' in their name. Please post C++ Builder questions in C++
Builder newsgroups.
Follow ups set to:
borland.public.cppbuilder.language.cpp
. Ed
Quote
Checco wrote in message
news: XXXX@XXXXX.COM ...

I need to adapt a project developped with DEV-C++ with
gnu g++, into
Borland C++ builder 5.0 but I'm in trouble with one error...
The follow code...

#include <string>
#include <algorithm>
#include <iostream>


//--------------------------------------------------------------------
------
Quote
-
#pragma hdrstop

//--------------------------------------------------------------------
------
Quote
-
#pragma argsused
int main(int argc, char* argv[])
{
std::string str = "io non so cosa fare";
str.erase(std::remove(str.begin(), str.end(), ' '),
str.end());
std::cout << str << std::endl;

system("pause");
return 0;
}

//--------------------------------------------------------------------
------
Quote

works correctelly with GNU g++ 3.2 and reply with:
iononsocosafare
Premere un tasto per continuare...
... but it doesn't work with Borland c++ Builder 5.0

I recive the follow errors ...

[C++ Error] Unit1.cpp(15): E2227 Extra parameter in call to
std::remove(const char *)
[C++ Error] Unit1.cpp(15): E2285 Could not find a match for
'_STL::string::erase(int,char *)'
 

Re:Help... I don't understand one compile error...

As you can see from Mr Maeder's message, I was wrong. While remove is
the file deletion function there is also another remove that is
exactly like the one you are using.
Read his message. He seems to think that the problem would disappear
if you included another header file.
. Ed
Quote
Checco wrote in message
news: XXXX@XXXXX.COM ...