AP Computer Science Workshop
C++ Functions
In C++A function that takes no parameters has an empty parameter list:
- everything is a function
- a procedure is a function that doesn't return anything (a void function):
Pascal Procedure Example:
procedure Foo (x, y : real; var a, b : integer); begin end;C++ Function Example:void Foo(double x, double y, int & a, int & b) { } Foo(3, 4, one, two);void PrintInstructions( ) { cout << ... }But be very careful with functions that take no parameters:PrintInstructions( );is not the same asPrintInstructions;
Mark Stehlik, Carnegie Mellon University