How to reserve memory for a slice in a struct

Namal sotis22 at mail.ru
Tue May 7 03:29:43 PDT 2013


Hello,

I am new to D. According to that power of 2 rule I want to
reserve 2 sized chunks to my array, But how do I do that in a
struct? Say:

struct Stack(int){

int a[];


}


Where do I put that a.reserve(2);

Because right after the declaration of a I get an error

Error: unexpected ( in declarator
Error: basic type expected, not 2
Error: found '2' when expecting ')'
Error: no identifier for declarator a.reserve(int)
Error: semicolon expected following function declaration
Error: Declaration expected, not ')'


More information about the Digitalmars-d-learn mailing list