C++ classes and structs

The language C had structs which held only data. When C++ was created, it was natural to extend the notion of a struct to hold data and functions. And this became the C++ class.

Programmers still use the struct and class in this way. Structs hold only data and classes hold data and functions. Classes in C++ are used in the exact same as they are in Java. You have the objects of a class. You can think of a class as a type. And so on.

That's in practice and you should do that too. But, as far as the C++ language itself, structs and classes are much closer. In C++, you can put functions in a struct, even if programmers don't. The only language difference between a struct and a class is that by default, without specifying it, everything in a struct is public, and by default, everything in a class is private.

So the following struct and class are used in an identical manner:
   struct Name1 {
      // bunch of stuff

   class Name2 {
      // same bunch of stuff