0

问题是这样的:我尝试使用 class progress_display(boost/progress.hpp) 来计算和显示我的程序的进度。正确使用类:

1.Instantiation: progress_display pd(count);
2.for(  ;  ;  ){
       pd++;
    }
3.With the increment of 'pd', the progress is display in console in real-time.

我的麻烦:做大部分计算的核心函数是一个迭代函数,我试图将对象'pd'传递给那个函数,这样当一个子迭代函数的执行完成时,对象'pd'将携带退出“++”操作。

#include<Windows.h>
#include<boost/progress.hpp>
using namespace std;
using namespace boost;

void functest(progress_display pdInput){
    pdInput++;
}
int _tmain(int argc, _TCHAR* argv[])
{
    vector<int> L;
    progress_display pd(100);
    functest(pd);
    return 0;
}

但是,这里出现一个错误:错误 C2248:"boost::noncopyable_::noncopyable::noncopuable": 无法访问私有成员(在类中声明"boost::noncopyable_::noncopyalbe)。

我仍然不知道这个错误来自实例化对象的错误使用,这将发生在所有公共类中还是与导入的boost库有关?

感谢任何能给我更多有用信息的人!

4

1 回答 1

1

progress_display不能被复制,所以不要将它作为参数传值。通过 [const] 引用或指针传递。

于 2012-09-05T13:10:49.997 回答