【发布时间】:2016-11-16 04:25:48
【问题描述】:
我想要一个包含多个 blitz++ 数组的结构。该程序创建了这样一个结构,但是我无法正确分配对象。将带有 pointers 的结构制定为在结构外部分配的 blitz++ 数组的唯一替代方法是什么?
#include <iostream>
#include <blitz/array.h>
using namespace std;
using namespace blitz;
struct Bstruct{
Array<double,1> B;
};
int main(){
Bstruct str;
Array<double,1> x(10);
x = 1.0;
str.B = x;
cout << "x = " << x << endl;
cout << "str.B = " << str.B << endl;
return 0;
}
➜ blitz_struct git:(master) ✗ ./struct
x = (0,9)
[ 1 1 1 1 1 1 1 1 1 1 ]
str.B = (0,-1)
[ ]
【问题讨论】:
-
上面截取的代码末尾显示了程序的输出。
x和str.B应该是一样的。 -
大概
blitz::Array没有提供正确/深拷贝赋值运算符。而且它明显的主页已经关闭,所以我无法检查标题! -
是的,我知道主页已关闭,这真的很痛苦。无论如何,这暂时有效。