我开始编程,我说英语不好,对不起。在struct C++中使用列表
我喜欢用一个列表,而不是一个数组,一个结构里面,像这样:
#include <iostream>
#include <list>
using namespace std;
struct Market {
string b;
list <int> prices;
};
int main()
{ list <int> precios;
Market m1 = {"a",NULL};
return 0;
}
,但我从要求int' to non-scalar type std::list<int, std::allocator<int> >
得到这个错误转换|
这可能吗?也许与malloc或免费?
'prices'不是指针,但它看起来像你希望它是 –