Mail Archives: djgpp/1994/11/26/16:54:19
I was wondering what the exact differences betwen arrays and allocated pointers
are.
If you have:
int array[big];
array[i] = 1;
or int * ptr
ptr = new int[big];
ptr[i] = 2;
delete ptr
they both do about the same thing, but the first case makes your exe bigger.
I would think that the first case can be alot faster however. Is this correct?
Because if you are accessing an element, in the first case the compiler knows where
it is. It doesn't need to use a register for ptr and it doesn't even have to
dereference ptr. it can just add i to a constant number. to get the address.
Is this correct or have I completely lost it?
--
|\___
|O.o/
David Wu =(___)= Don't Drink
U and Derive
Disclaimer: This message may not be politically correct.
The message may not be grammatically correct.
- Raw text -