C++: Pass array created in the function call line
Posted
by
Jarx
on Stack Overflow
See other posts from Stack Overflow
or by Jarx
Published on 2011-02-15T22:58:51Z
Indexed on
2011/02/15
23:25 UTC
Read the original article
Hit count: 200
How can I achieve a result like somebody would expect it according to the following code example:
// assuming: void myFunction( int* arr );
myFunction( [ 123, 456, 789 ] );
// as syntactical sugar for...
int values[] = { 123, 456, 789 };
myFunction( values );
The syntax I thought would work spit out a compile error.
- How can I define an argument array directly in the line where the function is called?
© Stack Overflow or respective owner