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)
[ ]

0

Решение

я нашел это на работу:

#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.resize(10);
str.B = 1.0;

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,9)
[ 1 1 1 1 1 1 1 1 1 1 ]
0

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector