Given your current code, you are indeed right, the function getHoursWorked is never called. Meaning it is completely useless in the code you currently provided. The program should still compile, the code is completely valid, part of it are just unused, meaning you might as well omit them and it would have the same result.
In C++ you can define all functions you want, it will only be executed if you call it. As an example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
#include <iostream>
void func1()
{
std::cout << "In function 1" << std::endl;
}
void func2()
{
std::cout << "In function 2" << std::endl;
}
void func3()
{
std::cout << "In function 3" << std::endl;
}
int main()
{
func1();
func3();
return 0;
}
|
This example would produce the following output:
In function 1
In function 3
|
As you can see, I defined a function named func2, but never called it. As a result, it isn't executed at all, which you can see in the output, there's no message saying "In function 2". Even though I defined the function, I'm not forced to call it. I would just have saved myself a few keystrokes by not typing the other function, other than that it is still valid in C++.