我试图将引用变量i_RootPath的值设置为while循环内的不同值,如果单击相应的按钮.编译不喜欢我分配i_RootPath的方式.它说:
没有可行的重载'='
如何从生成的按钮调用的不同方法中成功更改"i_RootPath"的值?
void NodeViewApp::AddToolbar( boost::filesystem::path& i_RootPath ) {
boost::filesystem::path currentPath = i_RootPath;
while( currentPath.has_root_path() ){
WPushButton* currentButton = new WPushButton( "myfile.txt" );
currentButton->clicked().connect( std::bind([=] () {
i_RootPath = currentPath;
}) );
currentPath = currentPath.parent_path();
}
}
Run Code Online (Sandbox Code Playgroud)