"声明会影响参数"是什么意思?

gra*_*ndx 8 c++ integer function

我试图创建一个函数,返回我将传递给它的整数的两倍.我的代码收到以下错误消息:

'int x'的声明会影响参数int x; "

这是我的代码:

#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;
}
Run Code Online (Sandbox Code Playgroud)

Sco*_*ter 21

你有x一个参数,然后尝试将它也声明为一个局部变量,这是关于"阴影"的投诉所指的.