Hi,
I'm just wondering, why do we bother with function prototypes? Wouldn't it be better if we just defined the functions before the main function instead of having a function prototype and a function definition in separate areas?
For example, instead of the following:
#include <iostream>
using namespace std;
void sayHello();
int main() {
sayHello();
return 0;
}
void sayHello() {
cout << "Hello!" << endl;
}
Why can't we just use this instead:
#include <iostream>
using namespace std;
void sayHello() {
cout << "Hello!" << endl;
}
int main() {
sayHello();
return 0;
}
Thanks for the time and help.