Explain the error in the following code. You may give the warning message, or error message, your compiler might give for the following error, or you may describe the error. However you present the error, you must explain clearly what is wrong.
```
#include
//Test question
void show_array(int ar[], int size)
{
using namespace std;
for(int i = 0; i < size; i++)
cout << ar[i] << " ";
cout << endl;
}
int main()
{
const int a[6] = {2, 4, 2, 3, 5};
show_array(a, 6);
//...
}
```
```
void show_array(int ar[], int size)
{ //^^^^ should be const to use a as an
//argument.
//. . .
}
show_array(a, 6);//warning: pointer to const given for
//argument 1 of 'void show_array(int*, int)'
```
The error message means that the compiler thinks the argument could be changed by the function, and considers this a violation of the programmer's promise not to change the array when the array was declared const.
You might also like to view...
In the United States, 3M labels are the most commonly used labels
Indicate whether the statement is true or false
Why should escalation requirements be considered as part of an incident response strategy?
A. Because all exploits take advantage of software flaws B. Because some hackers are smarter than others C. Because not all violations represent the same threat to an organization D. Because some countermeasures are more expensive than others