Re: array initilization and memory usage



I don't think so. new Bar[500] will alocate an array of references. Each
bars[i] = new Bar() will allocate a Bar so you'll end with an array of 400
references and 5 Bar allocated.

<jon23d@xxxxxxxxx> a écrit dans le message de
news:1151298741.400576.235390@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I'm a little new here, so please bear with me if this sounds like a
goofy
question!...

let's say that I have an class with 15 or so members, each taking up a
fair
amount of space - we'll call this class bars

If I create an array of 400 empty bars objects, but only instantiate
the
first five or so then am I still setting aside the memory for the other
395?

I hope that made sense!

Thanks



.



Relevant Pages

  • Re: 0xC000 0005 exception in CFrameWnd::OnCmdMsg()
    ... The problem was a stupid typo on my part; I had reduced an array size but a factor of 100 and was initialising it off the end using the wrong but similarly named constant. ... my status bar indicators and I get farther before I crash. ... NULL (not sure if this okay or not). ... gordon at gordys dot demon dot co dot uk ...
    (microsoft.public.vc.mfc)
  • Re: Differance between Array and Pointers
    ... when I see bar[] I do think of it as an array ... I also sorta think of it as a pointer. ... The first one also makes it harder in C to handle the array ... .L45 db "hello",0 ...
    (comp.arch.embedded)
  • Re: semantic difference between [][] and **
    ... or initializing the array such that ... > It is my understanding that foo and bar can be accessed and passed ... 'foo' is an array of arrays, ...
    (comp.lang.cpp)
  • Re: possible to use vlookup with multiple lookup values?
    ... It'd be easier to understand if you could put the multiple array comparisons ... You want to lookup Foo and Bar and return the corresponding numeric value ... SUMPRODUCT function to get the result. ...
    (microsoft.public.excel)
  • Re: unfamiliar array reference
    ... I've learned more about references and also about scoping of variables ... saying $bar ... #now scope of 'our' has ended, ... as an array - I tried commented-out options one at a time. ...
    (perl.beginners)