What does it mean that “a declaration shadows a parameter”?

I am trying to make a function that returns double the integer number that I will pass to it. I am getting the following error message with my code:

declaration of ‘int x’ shadows a parameter int x; “

Here is my code:

#include <iostream>
int doublenumber();
using namespace std;
int doublenumber(int x)// <-- this is the function which returns double the value .
{
    int x;
    return 2 * x;
    cout << endl;
}
int main()
{
    int a;
    cout << "Enter the number that you want to double it : " << endl;
    cin >> a;
    doublenumber(a);

    return 0;
}

Leave a Comment