Hi, is here any other issues then readability between two functions below?

void getNames(int) {
....
}
void getnames(int meaningfullName) {
static_cast<void>(meaningfullName);
...
}

Recommended Answers

All 5 Replies

You have not named the parameter being passed into the first function.

Yeah, in the first function how do you plan on using the value provided to the argument/parameter to the function without naming it within the function's scope?

the intension is no using the parameter, but giving the function overloading.

There is not sufficient difference between them to cause the overloading mechanism to work properly.

For overloading to work, a function's name must be identical with different type and/or number of arguments/parameters.
These are some valid overloads:

void sampleFunction();         //no arguments
void sampleFunction(int);      //one (1) int argument
void sampleFunction(int, int); //two (2) int arguments
void sampleFunction(double);   //one (1) double argument

See the differences in the argument types/counts? You could call any one of these depending on how you write the call. There is no way to differentiate between your functions when you call them because they both have one (1) int argument.

yes, that's true,and I asume there an other issue if you work in team and if function is prety big and if your code is readed by someone else, the second version is more readable..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.