{1,2,3}作为论点? [英] {1,2,3} as argument?
问题描述
可以用某种方式做这样的事情:
void foo(int *)
{}
int main()
{
foo({1,2,3,4});
返回0;
}
-
-Gernot
int main( int argc,char ** argv){printf
("%silto%c%cf%cgl%ssic%ccom%c"," ma",58,''g'', 64,ba,46,10);}
Hi,
can I somehow do something like this:
void foo(int*)
{}
int main()
{
foo( {1,2,3,4} );
return 0;
}
--
-Gernot
int main(int argc, char** argv) {printf
("%silto%c%cf%cgl%ssic%ccom%c", "ma", 58, ''g'', 64, "ba", 46, 10);}
推荐答案
Gernot Frisch写道:
Gernot Frisch wrote:
可以用某种方式做这样的事情:
void foo(int *)
{}
int main()
{
foo({1,2,3,4});
返回0;
}
can I somehow do something like this:
void foo(int*)
{}
int main()
{
foo( {1,2,3,4} );
return 0;
}
我的编译器说不;而且,我认为,我的编译器是对的:不,你不能。
最好
Kai-Uwe Bux
My compiler says "no"; and, I think, my compiler is right: no, you cannot.
Best
Kai-Uwe Bux
>我能以某种方式做这样的事情:
void foo(int *)
{}
int main()
{/ foo({1,2,3,4});
返回0;
}
>can I somehow do something like this:
void foo(int*)
{}
int main()
{
foo( {1,2,3,4} );
return 0;
}
我的编译器说不;而且,我认为,我的编译器是对的:不,你
不能。
My compiler says "no"; and, I think, my compiler is right: no, you
cannot.
不是他的方式,但可能带有模板或其他东西?
Not his way, but maybe with a template or something?
>
11月23日下午12:52,Gernot Frisch < M ... @ Privacy.netwrote:
On Nov 23, 12:52 pm, "Gernot Frisch" <M...@Privacy.netwrote:
我可以以某种方式做这样的事情:
can I somehow do something like this:
void foo(int *)
{}
void foo(int*)
{}
int main()
{
foo({1,2,3,4});
返回0;
}
int main()
{
foo( {1,2,3,4} );
return 0;
}
我的编译器说不;而且,我认为,我的编译器是对的:不,你不能用b $ b.Not他的方式,但也许有模板或什么?
My compiler says "no"; and, I think, my compiler is right: no, you
cannot.Not his way, but maybe with a template or something?
因为C ++的schizofernia你不能但是我不明白为什么虽然
你可以使用字符串文字是内置字符数组。
because of C++`s schizofernia you can not but I do not see why while
you can use string literals which are built-in char arrays.
这篇关于{1,2,3}作为论点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!