|
|
Object
s on the heap. Wouldn't the second alternative do the same thing, in that case?Object*
would be faster - whenever its size needs to be increased, assuming the space in memory right next to is is unavailable, everything would need to be recreated at another place in memory, right? If so, simply copying the addresses of the objects would be faster than just copying them altogether, I assume.
|
|
LargeObject
s, and I needed to regularly increase the size of it, which of the alternatives above would be better?
|
|
new
and therefore you must use delete
too. Not just use, but in right places too. Thus, you would rather use smart pointers or containers, rather than raw pointers.std::vector<Object> obs1( 2 );
|
|
new
or malloc
for a variable of the same size?
std::string
s. Would it be faster to use vector<string>
or vector<string*>
?
Schulter wrote: |
---|
All right - if I go back to my original point, say I have an array of a hundred std::string s. Would it be faster to use vector<string> or vector<string*> ? |
|
|
std::vector
. No, I don't know why, but that's not what I meant, either.
|
|
|
|
|
|
|
|
Object
s?
vector
, list
and deque
, and a list is not that good for direct access.