这是好风格吗?

Aus*_*ore 1 c++ coding-style parameter-passing

我的函数中有一些参数接收并传递相同的值.我应该将所有参数变量命名为相同吗?

例:

// assume numMonth = 12
// assume numYear = 2000

int promptMonth(); // returns numMonth
int promptYear();  // returns numYear

int daysInMonth(int numMonth, int numYear); // numMonth and numYear will always
int daysInYear(int numYear);                // be sent to these.

bool isLeapYear(int numYear);               // daysInYear() and daysInMonth() call
                                            // this function and send it numYear 
                                            // (which would be 2000 in this case).
Run Code Online (Sandbox Code Playgroud)

是否所有这些参数都被命名为相同,因为相同的值被传递给它们?

Alo*_*ave 6

同样,我假设你的意思是函数参数名称numYear.

是的,最好以有意义的方式命名变量,这表明传递的值的含义/目的.

并且这些变量是不同函数的一部分,因此范围仅限于那些函数.因此,如果您正在考虑这个问题,则不存在多个定义的问题.