"jeffc" <no****@nowhere.com> wrote in message news:<40********@news1.prserv.net>...
"Allan Bruce" <al*****@TAKEAWAYf2s.com> wrote in message
news:c5**********@news.freedom2surf.net...
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?
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.
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