说我有这样的课程
class TheBox{
public:
int value1;
int value2;
int **p;
int size;
int result;
int test(){
result = 0;
for (int i = 0; i < size; i++){
result += *p[i];
}
return result;
}
};
我像这样使用它
int main(){
TheBox b;
b.value1 = 5;
b.value2 = 7;
b.size = 10;
b.p = (int**)malloc(sizeof(int*)*b.size);
b.p[0] = &b.value1;
b.p[1] = &b.value1;
b.p[2] = &b.value2;
b.p[3] = &b.value1;
b.p[4] = &b.value1;
b.p[5] = &b.value2;
b.p[6] = &b.value2;
b.p[7] = &b.value1;
b.p[8] = &b.value1;
b.p[9] = &b.value1;
cout << b.host() << endl; //should output 56
b.value2 = 8;
cout << b.host() << endl; //should output 59
}
我的问题是我如何为对象做出cudaMemCpy&#34; b&#34;?
尝试复制数组时出现问题&#34; p&#34;我必须事先知道它是否包含value1或value2。
有没有办法正确地为对象做cudaMemcpy&#34; b&#34;没有这个信息?