This is a function
declaration:
bool endtime(int time) ;
You see the semicolon, don't you?
This is an
implementation of a function:
1 2 3 4 5 6 7
|
bool endtime(int time) // no semicolon here
{
if (end > start )
cout << timeDifference(start, end) << endl;
else if (start > end)
cout << "Error\n";
}
|
It is
illegal to implement a function inside another function. You almost had:
1 2 3 4 5 6 7 8 9
|
int main()
{
bool func(int time) // error: function inside body of another function
{
return time < 42;
}
}
|
A function that returns a Boolean value |
1 2 3 4 5 6 7
|
bool endtime(int time)
{
if (end > start )
cout << timeDifference(start, end) << endl;
else if (start > end)
cout << "Error\n";
} // where here was a 'return' statement?
|
A function that promises to return a value must do so too.
Your indentation is not consistent. It is hard to see that the loop is
inside the main(), because it is not indented like other statements in the
same scope.
Why is the 'runAgain' a global variable? It will be used only inside the main(), just like the 'end' and 'start'.
You don't modify the runAgain inside the loop. If it does not change there, then the loop will repeat forever.
6 14 [Warning] extended initializer lists only available with -std=c++11 or -std=gnu++11. |
A warning, not an error.
You do use brace initializer on line 6. Brace initializer was added in C++11 standard.
Your compiler does not support C++11 by default, but it can, if you ask for it.
You ask by adding
-std=c++11 to compiler's command line options.