本文介绍了结构数组的智能指针?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我有一些数据存储为普通的旧C结构。到目前为止,我已经在堆栈上有这些结构的数组,但由于堆栈溢出,我需要将这些结构移动到堆中。 我一直在尝试一些智能指针来帮助,但到目前为止,我一直在处理的 实现与[]运算符 有问题,因为它可以使用带有unsigned char的相同类时会发生冲突。 您对能够使用数组的智能指针有什么建议吗? 我需要类似的东西: ptr =(new或malloc)MY_STRUCT [16]; ptr [i] .member 谢谢。 - Henrik 解决方案 std :: vector有什么问题? 我忘了提到要求从外部C函数访问数据需要。因此,它需要像普通数组一样序列化。 - Henrik " Henrik Goldman" < he ************ @ mail.tele.dkwrote in message news:45 **************** *****@dread11.news.tele.dk。 .. 我忘了提到需要从外部C函数访问数据需要。因此,它需要像普通数组一样序列化。 - Henrik std :: vector符合这个要求。 http://www.parashift.com/c++-faq-lit....html#faq-34.3 vector存储它的内存连续的 Hi, I have some data which is stored as plain old C structures. Until now I''vehad arrays of these structs on stack but due to stack overrun I need to movethese to heap.I''ve been trying out some smart pointers to help but so far theimplementation I''ve been dealing with has had problems with [] operatorsince it could conflict when using the same class with "unsigned char". Do you have any recommendations for smart pointers able to work with arrays? I would need something like: ptr = (new or malloc) MY_STRUCT [16]; ptr[i].member Thanks. -- Henrik 解决方案 What is wrong with std::vector ?I forgot to mention that it''s a requirement that the data needs to beaccessible from external C functions. For this reason it needs to beserialized just like an ordinary array. -- Henrik I forgot to mention that it''s a requirement that the data needs to beaccessible from external C functions. For this reason it needs to beserialized just like an ordinary array.-- Henrikstd::vector fits the bill for that. http://www.parashift.com/c++-faq-lit....html#faq-34.3vector stores it''s memory contiguous 这篇关于结构数组的智能指针?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-25 09:49