Prototypes?

This is a discussion on Prototypes? within the C++ Programming forums, part of the General Programming Boards category; My instructor wishes for me to construct prototypes for a small program but I'm having a time figuring this out. ...

Yes i am. and could u finish the program so i can get a step by step basis of how to complete my programs. its a hybrid course so i have little help for the instructor. Thank you

Yes, I could do your homework for you, but that doesn't help you learn anything. There are examples of code all over the web, which you can learn from. Assignments are for you to actually gain practice from doing the work.

A function prototype is easy to understand if you know what a function is. Basically, a function prototype is used to tell the compiler that you have a function that you wrote. This lets the compiler store information on what types of variables it accepts and what type of variable it returns. When it comes across usage of your function and the definition of the function itself, it can verify that it matches the prototype. If it doesn't match, however, then the compiler can let you know something is wrong, and allow you the opportunity to go back and fix it.

In all honesty, probably nothing worth copying. I just posted what I have done in the past, and I'm open to changing it. Usually, it was done without much conscious thought.

I try to write my classes inside headers, and I need to have an idea how all of my classes generally interact. I imagine I write the names out because of this, because it helps me figure out what the class is doing in each function when I'm writing the headers before I write any actual implementation code.

In terms of C, I guess it's because I generally know from the name of the function and the types they take what is going on. Member functions have the added context of a class that they operate within. Non-member functions do not have that context. They operate in terms of the program (or the collection of other functions you're grouping them with), and I think potentially (depending on how you write your code of course) easier to figure out what they do.

All in all, I've heard both ends.... it's good to leave the names in, and it's good to not leave the names in. In terms of people that need to study the headers or prototypes and want to learn how to use your code, it's probably best to leave the names in as hints as to how the function works.