Re: retrieve size of array
Andrei Polushin wrote:
[...]
When the "independence" is the issue, then we might look deeper and
further, and notice that many public interfaces avoid dependence on
std::vector, but prefer C-style arrays, because of their predictable
binary representation.
Most such public interfaces avoid dependence on C++ completely,
and use a public interface defined in C. In practice, if
std::vector changes its layout, there's a pretty good chance
that vtable layout will change as well, as will name mangling,
and who knows what all else. Either the compiler guarantees
binary compatibility (which includes the layout of all of the
standard classes), or it doesn't.
Of course, even if you need to pass a C style array to a
function, you can (and normally should) still use std::vector to
allocate it.
--
James Kanze GABI Software
Conseils en informatique orient?e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S?mard, 78210 St.-Cyr-l'?cole, France, +33 (0)1 30 23 00 34
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]