Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ positional parameters

Tags:

c++

parameters

This is a very basic question, so please bear with me.

Consider the following function in C++:

void foo(int a, int b, int c)
{
   //do something
}

can I call this function like this: foo(b=2, c=3, a=2) ?

I suppose this have some sort of name (positional parameters, possibly). If you could clarify it in the answer too, it would great.

like image 991
nunos Avatar asked Nov 06 '09 12:11

nunos


People also ask

What are the positional parameters?

A positional parameter is a parameter denoted by one or more digits, other than the single digit 0 . Positional parameters are assigned from the shell's arguments when it is invoked, and may be reassigned using the set builtin command.

What is positional parameter example?

A typical example of a shell that uses positional parameters is bash. You can use bash on Linux, BSD, macOS X, and Windows 10. Consider the following bash command. The command name is mycommand.

What is a positional parameter in a command?

A positional parameter is a variable within a shell program; its value is set from an argument specified on the command line that invokes the program. Positional parameters are numbered and are referred to with a preceding ``$'': $1, $2, $3, and so on. A shell program may reference up to nine positional parameters.

What is positional parameter in SQL?

A positional parameter is set by its index in the clause. A named parameter is set by its name. When you are setting the values, you might have the values in an array, in which case the positional form could me more useful.


1 Answers

Not in standard C++, no. You'll have to provide the parameters in the order specified by the function prototype.

like image 183
Timo Geusch Avatar answered Sep 30 '22 00:09

Timo Geusch