Here's a code snippet I found here
void App::onSave()
{
if (filename.isEmpty())
return onSaveAs();
//do saving here
}
void App::onSaveAs()
{
QString f = QFileDialog::getSaveFileName(NULL, "Save as", "", "*.sb");
if (!f.isEmpty())
{
//filename generation
return onSave();
}
}
My question is: is there any difference between return onSave();
, as it is written here, and something like this:
onSave();
return;
It confused me because the functions are of void type and don't return anything.
The C++ standard says:
So the two forms are equivalent in C++.
Note that the C standard says:
The relaxation of this restriction in C++ probably has to do with templates.