const Arguments

In C++, an argument to a function can be declared as const as shown below:
int strlen(const char *p)
int length(const string &s);
The qualifier const tells the complier that the function should not modify the argument. The compiler will generate an error when this condition is violated. This type of declaration is significant only when we pass arguments by reference or pointers.

No comments:

Post a Comment