Skip to main content



      Home
Home » Language IDEs » C / C++ IDE (CDT) » BUG??: optional parameters in c++ functions call
BUG??: optional parameters in c++ functions call [message #157947] Mon, 14 November 2005 12:59 Go to next message
Eclipse UserFriend
Originally posted by: fbondioli.autentiweb.com

Hi everybody,

I've a newbie c++ question for you :)

I've a managed make c++ project using eclipse 3.0.1 and the latest
updated CDT plugin

I've a simple c++ function like this one:

std::string trim(std::string& s,const std::string& drop = " ")
{
std::string r=s.erase(s.find_last_not_of(drop)+1);
return r.erase(0,r.find_first_not_of(drop));
}


If I call this function this way:

std::string str = " TEST STRING ";
std::string myString = trim(str);

I get the error "too few arguments for function trim"

Isn't this a c++ feature?
The source code get fully compiled but the editors continue showing this
error.

I'm using mingw distribution, not cycgwin. Can this be the cause of the
problem?


Thanks for any hint.

Regards
JB
Re: BUG??: optional parameters in c++ functions call [message #158156 is a reply to message #157947] Wed, 16 November 2005 13:42 Go to previous messageGo to next message
Eclipse UserFriend
Fabio,

just tried it here, works with no problems.
- Does your file have the .cpp extension?
- Which compiler / os are you using?

Max

----
#include <iostream>
#include <string>

std::string trim(std::string& s,const std::string& drop = " ")
{
std::string r=s.erase(s.find_last_not_of(drop)+1);
return r.erase(0,r.find_first_not_of(drop));
}

int main()
{
std::string str = " TEST STRING ";
std::string myString = trim(str);
std::cout << myString << std::endl;
return 0;
}
----

Fabio B. wrote:
> Hi everybody,
>
> I've a newbie c++ question for you :)
>
> I've a managed make c++ project using eclipse 3.0.1 and the latest
> updated CDT plugin
>
> I've a simple c++ function like this one:
>
> std::string trim(std::string& s,const std::string& drop = " ")
> {
> std::string r=s.erase(s.find_last_not_of(drop)+1);
> return r.erase(0,r.find_first_not_of(drop));
> }
>
>
> If I call this function this way:
>
> std::string str = " TEST STRING ";
> std::string myString = trim(str);
>
> I get the error "too few arguments for function trim"
>
> Isn't this a c++ feature?
> The source code get fully compiled but the editors continue showing this
> error.
>
> I'm using mingw distribution, not cycgwin. Can this be the cause of the
> problem?
>
>
> Thanks for any hint.
>
> Regards
> JB
Re: BUG??: optional parameters in c++ functions call [message #158264 is a reply to message #158156] Thu, 17 November 2005 12:08 Go to previous message
Eclipse UserFriend
Originally posted by: fbondioli.autentiweb.com

Max ha scritto:
> Fabio,
>
> just tried it here, works with no problems.
> - Does your file have the .cpp extension?
> - Which compiler / os are you using?
>
> Max

Thanks a lot max for your reply...I've tested your code and it
worked...then I discovered it was my fault since I specified the default
value in the implementation of my function instead of into de declaration.

Sorry but I'm a newbie to c++ (I'm a Java programmer :)))

Fabio
Previous Topic:Standard make: 'Build path' does not work
Next Topic:Cannot set breakpoints
Goto Forum:
  


Current Time: Thu May 08 19:37:05 EDT 2025

Powered by FUDForum. Page generated in 0.03841 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top