C++ const constant function arguments

Description

C++ const constant function arguments

void aFunc(int& a, const int& b);  //declaration
int main()//from   ww  w  .  j  a v a  2  s  .  c  o  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
}



PreviousNext

Related