Chpater 6
Chpater 6
• Functions
− Called modules
− Like miniature programs
− Can be put together to form a larger program
• Syntax:
• The statement
static int x;
declares x to be a static variable of the type int
• Static variables declared within a block are
local to the block
−Their scope is the same as any other local
identifier of that block
C++ Programming: From Problem Analysis to Program Design, Fourth Edition 70
Function Overloading: An
Introduction
• In a C++ program, several functions can have
the same name
− This is called function overloading or
overloading a function name
• Syntax error:
• Assume:
− a, b are int, ch is char, d is double
• Examples of legal calls: