Demonstrate constant function arguments - C++ Function

C++ examples for Function:Function Parameter

Description

Demonstrate constant function arguments

Demo Code

void aFunc(int& a, const int& b);  //declaration
int main()//  w w w . j  a  va  2 s.co  m
{
  int alpha = 7;
  int beta = 11;
  aFunc(alpha, beta);
  return 0;
}
void aFunc(int& a, const int& b)   //definition
{
  a = 107;   //OK
  //b = 111;   //error: can't modify constant argument
}

Related Tutorials