| re: You learn something new every day...
"jeffc" <nobody@nowhere.com> wrote in message news:<407eb31e_4@news1.prserv.net>...[color=blue]
> "Allan Bruce" <allanmb@TAKEAWAYf2s.com> wrote in message
> news:c5m3ui$mo5$1@news.freedom2surf.net...[color=green]
> >
> > Apparantly the difference between structs and classes is that a class has
> > default private access, and a struct has default public access! Well, I
> > never!
> >
> > Are there any other differences?[/color]
>
> Similar idea when inheriting regarding the default, but otherwise they are
> more or less 2 words for the same thing. Some programmers will use "struct"
> when the "class" has no functions, but this is a style issue, not technical
> issue.[/color]
To quote Bjarne Stroustrup:
- Which style you use depends on circumstances and taste. I usually
prefer to use struct for classes that have all data public. I think of
such classes as "not quite proper types, just data structures" .
Constructors and access functions can be quite useful even for such
structures, but as a shorthand rather than guarantors of properties of
the type.
- Use public data (structs) only when it really is just data an no
invariant is meaningful for the data members.
Source: The C++ Programming Language, Third Edition
----
//rk |