| re: initializing heap-allocated structs
"Samuele Armondi" <sammyboyuk_NOSPAM_@hotmail.com> wrote in message
news:3f395f34_3@mk-nntp-1.news.uk.worldonline.com...[color=blue]
> "Wolfgang Jeltsch" <jeltsch@tu-cottbus.de> wrote in message
> news:bhblvh$vocjc$1@ID-77306.news.uni-berlin.de...[color=green]
> > Hello,
> >
> > I can initialized, e.g, heap-allocated ints by writing something like
> > new int(5).
> > Now I'd like to know if it is possible to do the same thing for struct
> > types. Say, I have a struct declared by the following lines:
> > struct S {
> > int i;
> > const char c;[/color]
>
> Add a constructor:
> S(int _i, char _c) : i(_i), c(_c);[/color]
Sorry, typo slipped in... That should be:
S(int _i, char _c) : i(_i), c(_c) {};
[color=blue]
>[color=green]
> > }
> > I want to write something like
> > new S {5, 'd'}.[/color]
>
> Make that new S(5, 'd');
>
> HTH,
> S. Armondi[color=green]
> > Is this possible?
> >
> > Wolfgang[/color]
>
>[/color] |