Classess have constructors, that can be
struct was upgraded in C++ and can do all of that too.
Try it.
I personally stopped using the class keyword and went
back to struct. The reason is I can eliminate that silly
"public:" statement at the beginning needed to expose the
constructor. In the end, "class" proved to be just an
unnecessary annoyance with no value add for me. I do use
public, protected, and private extensively to define
structs.
Indeed. I think that 'class' and 'struct' where meant to be equivalent. I never
touched another class after reading what Bjarne Stroustrup wrote about it in the
Annotated C++ Reference Manual, Addison-Wesly Publishing Company, 1995,
Paragraph 11.2:
<quote>
(...) For example, novices often don't know about access specifiers and get
confused by this:
class X { public: f(); };
class Y : X { }; // no access specifier
// private by default
void g(Y* p)
{
p->f(); // error
}
Even experts can get caught. A compiler can be most helpful by issuing a warning
for the missing access specifier.
Having private as the default was chosen to reflect the general view that
things that are not explicitly declared public are private. Defining a default
access specifier was probably a mistake.
</quote>
He says that the default access specifier 'private' for classes was a mistake.
There should have been _no_ default access specifier, ie class should be
'public' by default, just like struct is. The difference between class and
struct is based on a mistake. A class was meant to act just like a struct does.