gpt4 book ai didi

c++ - 构造函数谁 spect void*

转载 作者:搜寻专家 更新时间:2023-10-31 02:20:17 25 4
gpt4 key购买 nike

我有一个这样的函数:

void mouseHandler(int event, int x, int y, int flags, void *roi){
roi->foo=foo;
....
}

我想称它为发送这样的结构:

struct Roi{
Point point1, point2;
int drag;
Rect rect;
Mat img, roiImg;
int select_flag;
};
struct Roi roi;
cvSetMouseCallback("image", mouseHandler, (void*)&roi);

我有问题,因为我不知道该怎么做...请帮忙

最佳答案

在访问成员之前,您需要将 roivoid* 转换为 Roi*

Roi* realRoi = static_cast<Roi*>(roi);
realRoi->foo=foo;

关于c++ - 构造函数谁 spect void*,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32898718/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com