几个小时以来我一直在尝试修复这个错误,但我遗漏了一些东西:
我有一个结构声明为:
typedef struct {
bool active;
unsigned long bbcount;
char buffer[BUFFSIZE];
std::set<__uint> *bblist;
} per_thread_t;
稍后我为它分配内存并设置一些变量,包括像这样的 set
:
per_thread_t *data = (per_thread_t *)malloc(sizeof(per_thread_t));
data->active = false;
data->bblist = new std::set<__uint>();
data->bblist.find(6328);
但我收到错误error C2228: left of '.find' must have class/struct/union
。
我在这里做错了什么?
谢谢
最佳答案
bblist
是指针类型。您需要像这样访问它:
data->bblist->find(6328);
关于c++ - 类类型错误 C++ with struct,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36228103/