Write a function called max_size that takes a vector of strings as an input and returns the string with the maximum length. code example
Example: Write a function called max_size that takes a vector of strings as an input and returns the string with the maximum length.
// ALWAYS USE PASS BY REFERENCE WITH STRINGS AND VECTORS.
string max_size (const vector <string> & v)
{
string result;
for (int i = 0; i < v.size(); i++)
{
if ( v[i].length() > result.length() )
{
result = v[i];
}
}
return result;
}