添加對象我有以下的Structs:在數組C++
struct Photo{
char name[30];
};
struct List {
Element *data;
int count;
int capacity;
};
和typedef Photo* Element;
另外,我有類型的「列表」的數組:List *list = new List[100];
和類型的「照片」的元素: Photo *e = new Photo;
我想在數組列表的開頭插入元素「* e」。我正在使用以下C++語句: list -> data[0] = e;
但是,我結束了Segmentation fault: 11
錯誤。
我用C++新的,我需要知道我怎麼可以保存元素「E」中的數組「列表」
[使用std :: vector](http://en.cppreference.com/w/cpp/container/vector) – StoryTeller 2013-03-06 21:27:26
你有沒有考慮過使用'std :: vector'? – JBentley 2013-03-06 21:27:45
'std :: vector'也可能使用'std :: string'作爲名字。 –
111111
2013-03-06 21:28:55