c++ - 表达式必须是可修改的左值 - 结构中的数组

标签 c++ pointers multidimensional-array struct callback

我需要传递两个数组 (int[1024][3]int[1024][4]) 和一个 Mat* > (OpenCV 矩阵)到回调函数。
我有这样的结构:

 struct data_holder {
     Mat* mat;
     unsigned int* data[4];
     unsigned int* tara[3];
     //unsigned int tara[1024][3];  //Previous attempt
     //unsigned int data[1024][4];  
 }

这是我的作业:

 Opencv_Button pokus = Opencv_Button(20,40,50,20);  //Creating button class instance
 pokus.val("Tara");  //Button title
 ui.addButton(&pokus);  //Adding button to UI
 data_holder but_data; //structure
 but_data.data = &data;  //!!Expression must be a modifiable lvalue!!
 but_data.tara = &tara;  //For unsigned int data[1024][4] in structure I did ... = data
 but_data.mat = &UI_tara;//Matrix assigned with no problems
 pokus.setCallback(taraButtonCallback, (void*)&but_data);

那么如何将两个数组和 Mat 对象传递给回调函数?

最佳答案

这个:

unsigned int* data[4];

是一个指针数组。数组不可赋值。

假设RHS的类型是int [1024][4],那么我有一种感觉,你真的想要这个:

unsigned int (*data)[1024][4];

关于c++ - 表达式必须是可修改的左值 - 结构中的数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15040018/

相关文章:

c++ - win32 std::thread 是否泄漏内存?

c++ - 反转数字的子序列

c++ - CUDA:请帮我找出代码中的错误

c++ - 创建单链表时正确设置指针的问题

c++ - RGB 到十六进制语法

c++ - 为什么 "TYPE* const"指针有不同的行为?

c - 当您传递已分配的值指针时,究竟会发生什么?

c - 测试元素是否为数组 c

python - 使用 x,y,z 排序将 1D numpy 数组 reshape 为 3D

PHP - 对多维数组进行排序时出现问题?