C++ Classes vs Structures
Table of Contents

Similarities

There's a common misconception that the C++ keywords class and struct are more different than they really are in C++.
The origin of this myth arises from C++'s C heritage. In C, there was struct, but no class, private:, protected:, or public:. C had no concept of member functions or constructors, and required each reference to the structure in question to be prefixed by the keyword struct (or, alternatively accessed through a typedef which did this), and everything was publicly accessible.

This resulted in most C structures looking like:

typedef struct A_ {
    int b;
    char c;
} A;
void FunctionWorkingOnA( A* );

C++ introduced the concept of classes, with constructors, destructors, data hiding, member functions, and did away with the class-prefix-or-typedef requirement. However, in large part, no distinction is made between class and struct, so all these changes apply to struct as well. class and struct are practically identical. Yes, that means you can have a struct with private members, virtual member functions, constructors, etc.

Differences

Really, there's only one major difference between class and struct in C++: default visibility.

Everything (members and inheritence) defaults to public: for struct, and private: for class. An exhaustive example of the various scopes:

class Class : A, public B, protected C, private D {
    // anything here will be **private**, as will A's inheritence.
public:
    // anything here will be public
protected:
    // anything here will be protected
private:
    // anything here will be private
};

struct Structure : A, public B, protected C, private D {
    // anything here will be **public**, as will A's inherience.
public:
    // anything here will be public, same as with Class
protected:
    // anything here will be protected, same as with Class
private:
    // anything here will be private, same as with Class
};