这是一个非常基本的问题,请耐心等待.
考虑C++中的以下函数:
void foo(int a, int b, int c)
{
//do something
}
Run Code Online (Sandbox Code Playgroud)
我可以这样调用这个函数:foo(b=2, c=3, a=2)?
我想这有某种名称(可能是位置参数).如果你也可以在答案中澄清它,那就太好了.
使用核心c ++功能是不可能的.但是在boost集合中有一个库可以实现这一点.
使用boost.parameters你可以这样:
#include <boost/graph/depth_first_search.hpp> // for dfs_visitor
BOOST_PARAMETER_FUNCTION(
(void), depth_first_search, tag
…signature goes here…
)
{
std::cout << "graph=" << graph << std::endl;
std::cout << "visitor=" << visitor << std::endl;
std::cout << "root_vertex=" << root_vertex << std::endl;
std::cout << "index_map=" << index_map << std::endl;
std::cout << "color_map=" << color_map << std::endl;
}
int main()
{
depth_first_search(1, 2, 3, 4, 5);
depth_first_search(
"1", '2', _color_map = '5',
_index_map = "4", _root_vertex = "3");
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2200 次 |
| 最近记录: |