How to handle variable number of arguments?

L

Lambda

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?
 
D

Darío Griffo

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;
}
 
L

Lambda

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;

}

I've never use default argument that way, thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top