Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.c++.moderated    |    Moderated discussion of C++ superhackery    |    33,346 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 31,558 of 33,346    |
|    Francis Glassborow to Ebi    |
|    Re: Creating a dynamically allocationg o    |
|    11 Oct 11 20:20:34    |
      27474eda       From: francis.glassborow@btinternet.com              On 11/10/2011 18:16, Ebi wrote:       > Is it possible to create an object that accepts large amount of data and       > probably needs to be copied to another block of RAM with a "new" keyword ?       > Consider std::vector, i.e. pointer = new std::vector       > if I add too many objects to the vector then probably object copies itself to       > another address in RAM, then pointer changes, then how can I access the       object ?       >              I can think of no good reason for wanting to do something like that. A       std::vector manages its resources internally which is why it can       relocate its elements. Indeed the implementation of std::vector is an       example of how to handle relocating data without having to keep an       external track of it.              However if you did do what your example suggests it would not cause a       problem because the vector does not move!! It is its internal data       storage that moves. Of course if you insisted on keeping a pointer to       one of its elements you would have a problem but that is something       different.                     --        [ See http://www.gotw.ca/resources/clcm.htm for info about ]        [ comp.lang.c++.moderated. First time posters: Do this! ]              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca