Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/126.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ Boost Python-在函数调用中丢失数据_C++_Boost Python - Fatal编程技术网

C++ Boost Python-在函数调用中丢失数据

C++ Boost Python-在函数调用中丢失数据,c++,boost-python,C++,Boost Python,我在boostpython中遇到了一个非常奇怪的问题。我将重点介绍一个特定的属性/方法来简化示例。情况如下: 在我的程序中,我有一个叫做攻击的类。使用以下布局(例如简化) 现在,因为我没有为这个攻击实例在Python中重写CalculatedMage,它最终解析为AttackWrapper::CalculatedMageDefault。但当我输入AttackWrapper::CalculatedMageDefault时,Hit不再为真。也就是说,当我在这条线上中断时: return this-&

我在boostpython中遇到了一个非常奇怪的问题。我将重点介绍一个特定的属性/方法来简化示例。情况如下:

在我的程序中,我有一个叫做攻击的类。使用以下布局(例如简化)

现在,因为我没有为这个攻击实例在Python中重写
CalculatedMage
,它最终解析为
AttackWrapper::CalculatedMageDefault
。但当我输入AttackWrapper::CalculatedMageDefault时,Hit不再为真。也就是说,当我在这条线上中断时:

return this->Attack::CalculateDamage(users, target, Targets, field);
Hit是假的。所以介于

return call_method<int>(self, "CalculateDamage", users, ptr(target), targets, ptr(field));

我的财产失去了价值。我不知道是什么原因造成的。以前有人遇到过这样的事情吗?我想它可能被复制了…

添加显式复制构造函数/constructor/destructor,并检查您的类是否在某个地方被值传递。
class_<Attack, AttackWrapper, boost::shared_ptr<Attack>, bases<Action> >("Attack")
    .def("CalculateDamage", &AttackWrapper::CalculateDamageDefault);
return call_method<int>(self, "CalculateDamage", users, ptr(target), targets, ptr(field));
return this->Attack::CalculateDamage(users, target, Targets, field);
return call_method<int>(self, "CalculateDamage", users, ptr(target), targets, ptr(field));
return this->Attack::CalculateDamage(users, target, Targets, field);