What can you "new"

Steve Teale steve.teale at britseyeview.com
Mon Mar 23 10:27:45 PDT 2009


bearophile Wrote:

> Steve Teale:
> > What am I missing here, isn't char[] a dynamic array?
> 
> I suggest you to post such questions to the "learn" newsgroup.
> 
> D dynamic arrays aren't objects, they are C-like structs that contain a just length and a pointer (no capacity). The "new" for them is needed only to allocate the memory they point to. So to define an empty dynamic array of chars:
> 
> char[] ca;
> In D1 you can also just:
> string s1;
> 
> To allocate a non empty array of chars of specified len:
> auto ca = new char[some_len];
> 
> Tale a look at the D docs, where such things are explained.
> 
> Bye,
> bearophile

So how do you interpret the error message?





More information about the Digitalmars-d mailing list