Connecting Tech Pros Worldwide Help | Site Map

How to handle variable number of arguments?

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 3rd, 2008, 12:45 PM
Lambda
Guest
 
Posts: n/a
Default How to handle variable number of arguments?

How to define such a function that:

1. Accept variable number of std::string arguments,
can be 1, 2, or 3 arguments.
2. Find the longest common prefix of all these strings and
return the position of the end of the longest prefix?

  #2  
Old July 3rd, 2008, 01:05 PM
=?ISO-8859-1?Q?Dar=EDo_Griffo?=
Guest
 
Posts: n/a
Default Re: How to handle variable number of arguments?

int myfunc(const std::string& first=std::string(),const std::string&
second=std::string(),const std::string& third=std::string())
{
int where;
bool match=false;
//do somestuff)
if(!nomatch)
return -1;
return where;
}

Lambda wrote:
Quote:
How to define such a function that:
>
1. Accept variable number of std::string arguments,
can be 1, 2, or 3 arguments.
2. Find the longest common prefix of all these strings and
return the position of the end of the longest prefix?
  #3  
Old July 3rd, 2008, 01:35 PM
Lambda
Guest
 
Posts: n/a
Default Re: How to handle variable number of arguments?

On Jul 3, 8:56*pm, Darío Griffo <dario.griffo.lis...@gmail.comwrote:
Quote:
int myfunc(const std::string& first=std::string(),const std::string&
second=std::string(),const std::string& third=std::string())
{
int where;
bool match=false;
//do somestuff)
if(!nomatch)
return -1;
return where;
>
}
Lambda wrote:
Quote:
How to define such a function that:
>
Quote:
1. Accept variable number of std::string arguments,
can be 1, 2, or 3 arguments.
2. Find the longest common prefix of all these strings and
return the position of the end of the longest prefix?
>
>
I've never use default argument that way, thanks!
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.