Function Signatures

The portion of a function prototype that includes the name of the function and the types of its arguments is called the function signature or simply the signature. The function signature does not specify the function’s return type. Functions in the same scope must have unique signatures. The scope of a function is the region of a program in which the function is known and accessible. We’ll say more about scope in Section 6.10.

In Fig. 6.2, if the function prototype in line 16 had been written

void maximum( int, int, int );

the compiler would report an error, because the void return type in the function prototype would differ from the int return type in the function header. Similarly, such a prototype would cause the statement

cout << maximum( 6, 7, 0 );

to generate a compilation error, because that statement depends on maximum to return a value to be displayed.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.98.186