Use a const pointer parameter : const parameters « Function « C++ Tutorial






#include <iostream> 
using namespace std; 
 
int f(const int *val); 
  
int main() 
{ 
  int result; 
  int v = 10; 
 
  result = f(&v); 
 
  cout << v << " fd is " << result; 
  cout << "\n"; 
 
  return 0; 
} 
 
int f(const int *val) 
{ 
  return - *val; 
}
10 fd is -10








7.7.const parameters
7.7.1.Use a const pointer parameter
7.7.2.const reference