"Cy Edmunds" <cedmunds@spamless.rochester.rr.com> wrote in message
news:c84Ib.14968$q55.1324@twister.nyroc.rr.com...[color=blue]
> "slurper" <slurper1234@hotmail.com> wrote in message
> news:3ff0c83f$0$20545$ba620e4c@news.skynet.be...[color=green]
> > hi,
> >
> > i'm studying some stl. i saw the pair implementation in a header-file[/color][/color]
but[color=blue][color=green]
> > what i wonder is if a struct can have constructors as it seems in[/color]
> following[color=green]
> > snippet from the stl library. the snippets i wonder about are indicated
> > with --------> : i thought a struct doesn't have constructors (but here
> > there are four, actually three)
> >[/color]
>
> [snip]
>
> In C++, the only difference between a struct and a class is that all[/color]
members[color=blue]
> of a struct are public by default. Thus a struct can have a constructor or
> anything else a class can have.
>[/color]
I suspect that the poster was thinking that struct = POD (plain old (C
compatible) data).
Of course this isn't true but what may need pointing out is that even POD
can have some C++ stuff such as ctors and member functions.
Off the top of my head the only things it can't have (and still be POD) are:
- access specifiers
- virtual methods
- destructor
- references
- any member that isn't POD
There may also be restrictions on ctors
[color=blue]
> --
> Cy
>
http://home.rochester.rr.com/cyhome/
>
>[/color]