inkedmn
04-18-2003, 08:21 PM
i'm reading through this C++ tutorial and it's got this code:
#include <iostream.h>
int mult(int x, int y);
int main() {
int x, y;
cout<<"Please input two numbers to be multiplied: ";
cin>>x>>y;
cout<<"The product of your two numbers is "<<mult(x, y);
return 0;
}
int mult(int x, int y) {
return x*y;
}
now, i understand the second line is a function prototype, but it doesn't really say why that's done or if it's required for every function written (except main()).
eh?
#include <iostream.h>
int mult(int x, int y);
int main() {
int x, y;
cout<<"Please input two numbers to be multiplied: ";
cin>>x>>y;
cout<<"The product of your two numbers is "<<mult(x, y);
return 0;
}
int mult(int x, int y) {
return x*y;
}
now, i understand the second line is a function prototype, but it doesn't really say why that's done or if it's required for every function written (except main()).
eh?