Well, Prototype functions are interesting ... They work a lot like Void functions, but a lot differently.
// Listing 5.6 - demonstrates use
// of default parameter values
#include
int AreaCube(int length, int width = 25, int height = 1)
int main()
{
int length = 100;
int width = 50;
int height = 2;
int area;
area = AreaCube(length, width, height)
std::cout << "First time area equals " << area << "n";
area = AreaCube(length, width)
std::cout << "Second time area equals " << area << "n";
area = AreaCube(length)
std::cout << "Third time area equals " << area << "n";
std::cin.get()
return 0;
}
int AreaCube(int length, int width, int height)
{
return(length * width * height)
}
Like the void function, prototypes are also called by just typing the names. The integers set in the prototype function are default values for Length, Width, and Height. The bottom is the command that "AreaCube" which is Length * Width * Height . When AreaCube is typed in, it returns the values of each of the integers. Very basic, simple stuff.
Ehh ... I want to work on C++ more, so right now i'll just cut it down and show what comes up when you compile(debug) and run it.
Compilage
First time area equals 10000
Second time area equals 5000
Third time area equals 2500