this code does nothing cos it's wrong :)
function can be "described" in two ways:
first is DECLARATION:
int randomFunction (int, int);
second is DEFINITION:
1 2 3
|
int randomFunction (int x, int y) {
// some stuff here
}
|
DECLARATIONS must be "declared" before main () function or in header file (*.h) and then included with
#include "headerName"
command
where identifers are irrelevant (not inpotant)
what declaration does ->
it let the compiler know what type of argument functioin will take and what will reutn
and
DEFINITIONS are mostly "defined" after function main () or in seperate *.cpp file
where identifers must! be included otherwise wont work
what definition does ->
it tels the compiler exactly what funtion can do
DEFINITION and DECLARATION argument
types (int, double ...)must match otherwise compiler return's error and wont compile.
why to use declaration ?
you don't have to... u can use only definition but then definition must be before function main ()
in same file so the compiler will know that function exist and what it will do.
declaration are used because if u have many functions u will like to put them into seperate file and not mesed up wint your main code
1 more option is puting only definiton into header which is VERY BAD practice.
hope you got it :)