事实上,我会说,当你发现自己使用指针时,如果你确实需要它,请自己询问 。在大多数情况下,使用参考分配堆栈或 也一样好。 - Erik Wikstr?mThe elements contained in the vector are stored on the heap, noticethought that for some containers, std::vector among them, the elementsmight be re-located when you perform some operations on the containers,so taking the address of an object can be hazardous.In fact, I would say that when you find yourself using a pointer askyourself if you really need it. In most cases allocating on the stack orusing a reference is just as good.--Erik Wikstr?m 快速阅读本文但你可能想参考以前的帖子 我的: http://groups.google.com/group/comp .... 9d782f6d6dae52 google ptr_vectorquickly read this but you might want to refer to a previous post ofmine: http://groups.google.com/group/comp....9d782f6d6dae52also google ptr_vector 这篇关于我应该在容器内使用指针吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-16 03:05