Why should I use function prototypes?

Jan 26, 2011 at 9:39pm
C# really pissed me off so I decided to return to learn C++. However, I really don't get why I should use function prototypes. Is there any real reason, or is only to make sure that you don't make mistakes in the real function?

Thanks.
Jan 26, 2011 at 9:47pm
So that the compiler can check whether you are passing the right arguments and resolve overloading.
Jan 26, 2011 at 9:50pm
You do not have to use prototypes; so long as you define the function before you use it, it will work.

In addition to Bazzy's words, if you ever want to use a function that you did not write and are not going to be compiling yourself (which I expect is very, very often), the compiler must still know what will be passed in and what will be returned.
Last edited on Jan 26, 2011 at 9:56pm
Jan 27, 2011 at 1:23am
Function a calls function b
Function b calls function a


You would need to use a prototype in that situation, no way that I know of around it.
Topic archived. No new replies allowed.