C++ examples for Function:Function Parameter
Demonstrating the const type qualifier in parameter
#include <iostream> using namespace std; void tryToModifyArray( const int [] ); // function prototype int main() //from ww w . j av a 2s. c o m { int a[] = { 10, 20, 30 }; tryToModifyArray( a ); cout << a[ 0 ] << ' ' << a[ 1 ] << ' ' << a[ 2 ] << '\n'; } // "b" cannot be used to modify the original array "a" in main. void tryToModifyArray( const int b[] ) { //b[ 0 ] /= 2; // compilation error }