Possible Duplicate:
Pass by Reference / Value in C++
I have the following function. The parameters is index (a ms map) and key (a string). It search for the key and return a set with result or the message "file not found".
How to pass the map index by reference?
If I need search_sucess in another function, Is it better return it by pointer?
typedef map<string, set<string> > ms;
set<string> seach_set(ms index, string key)
{
ms::iterator result;
result = index.find(key);
set<string> search_sucess;
if (result != index.end())
{
cout << key << " in files : " << "{";
for(set<string>::iterator iter = result->second.begin();
iter != result->second.end(); ++iter)
{
cout << *iter << " ";
search_sucess.insert(*iter);
}
cout << "}";
}
else
{
cout << key << " not found ";
}
cout << endl;
return search_sucess;
}