是否可以将"未命名"变量传递给函数?

Tas*_*sos 2 c++

假设有以下功能:

void SetTheSize(const SIZE *size) { ... }
Run Code Online (Sandbox Code Playgroud)

有没有办法在不指定SIZE变量的情况下调用该函数?例如,

SetTheSize((const SIZE*)&{10, 10});
Run Code Online (Sandbox Code Playgroud)

编辑: 我应该提到SIZE是一个结构,没有SIZE(int,int)构造函数.

Nav*_*een 6

No, only thing nearest in C++ is to do like this:

void SetTheSize(const SIZE& size); //Change the pointer to const reference
Run Code Online (Sandbox Code Playgroud)

And call it using an unnamed temporary variable: SetTheSize(SIZE(10,10));