Classes versus Structs
In C++, you have a choice between declaring an object as a struct or a class. Both can utilize member functions and inheritance and have a mixture of public, protected, and private fields (more on these in later chapters). The main difference between a class and a struct is that a struct's member variables and methods are public, while a class's member variables and methods are private. In the following example, two equivalent data types are declared to show how a struct defaults (doesn't use public, private or protected keywords) its members to public while a class defaults to private:
struct MyStruct { int myInt = 0; // this defaults to public }; class MyClass { int myInt = 0; // this defaults to private }; int main() { MyStruct myStruct; MyClass myClass; // allowed - public int i = myStruct...