
Hello all, If you were to write a container that had a certain size, say 6, but may not always contain 6 items, say it contains 4, what would it be best to have the following methods do? size() - returns 6 or 4? end() - returns an iterator on the 5th or 7th element? I'm not sure if the standard way of writing such things dictates a certain approach, or if it is purely down to the intended use. Thanks for any information. Gaz ******************************* * http://planetearthworm.com/ * *******************************

Hi Gareth, My first comment is that this might not be the best newgroup to ask this in. "Foster, Gareth" <gareth.foster@siemens.com> wrote in message news:CC9F48B022FA5B46A295029EA3F713A62F1CCA@ntht205e.siemenscomms.co.uk... | Hello all, | | If you were to write a container that had a certain size, say 6, but may not | always contain 6 items, say it contains 4, what would it be best to have the | following methods do? | | size() - returns 6 or 4? | end() - returns an iterator on the 5th or 7th element? | | I'm not sure if the standard way of writing such things dictates a certain | approach, or if it is purely down to the intended use. | obviously you should only return 4 and the 5th element since otherwise you could go out of bounds in a loop. -Thorsten
participants (2)
-
Foster, Gareth
-
Thorsten Ottosen