|
||
|
Lesson 2
Objective
|
Function prototypes Re-code C program which uses traditional C function syntax |
|
|
The syntax of functions in C++ inspired the function prototype syntax found in ANSI C. A C++ function lists the types of the
function's parameters inside the header parentheses. Explicitly listing the type and number of arguments makes strong type
checking and assignment-compatible conversions possible.
ExampleThis list of a function's arguments in the header parentheses is called the function's signature. Let us consider a function min that determines the minimum of two numbers. It's prototype would be: int min(int, int); The function prototype can also include the identifier names of the arguments. In the case of min(), this would be: int min(int x, int y); Function Prototypes - Exercise
Click the Exercise link below to re-code a C program, which uses traditional C function syntax, as a C++ program that uses a proper
function prototype.
Function Prototypes - Exercise |
||
|
|
||