小编moo*_*oko的帖子

在 C++ 中有没有办法像在 python 中那样按名称传递参数?

在 C++ 中有没有办法像在 python 中那样按名称传递参数?例如我有一个功能:

void foo(int a, int b = 1, int c = 3, int d = 5);
Run Code Online (Sandbox Code Playgroud)

我可以以某种方式称它为:

foo(5 /* a */, c = 5, d = 8);
Run Code Online (Sandbox Code Playgroud)

或者

foo(5, /* a */, d = 1);
Run Code Online (Sandbox Code Playgroud)

c++ arguments function parameter-passing

-1
推荐指数
2
解决办法
678
查看次数

标签 统计

arguments ×1

c++ ×1

function ×1

parameter-passing ×1