Function prototypes

Just wondering should i just put my function before main so i dont have to prototype or after main and prototype?
So this:

int temp();

int main()
{

}
int temp(int x)
{

}



or this



int temp(int x)
{

}
int main()
{


}
Matter of preference.
I personally place whole definition before main. Some people separate declaration and definition as that way it is easier to move them to separate .h. and .cpp files.
It's standard practice to put the prototype before main() and the functions below main() in a procedural design. That being said, you should consider putting the prototypes in a header and just include the header. Then you would just #include the header in your main.cpp. I would also try keep main() all by itself in a main.cpp and put all functions in a separate .cpp. So you would have a functions.h, functions.cpp, and main.cpp.
Thank you. That cleared up a lot of things..
Topic archived. No new replies allowed.