![[Dept of Engineering]](http://www.eng.cam.ac.uk/images/house_style/engban-s.gif)
Variables of different types can be grouped into a structure or a class.
class person {
public:
int age;
int height;
string surname;
};
person fred, jane;
defines 2 objects of type person each of 3 fields. Fields are accessed using the `.' operator. For example, fred.age is an integer which can be used in assignments just as a simple variable can.
Structure and Class objects may be assigned, passed to functions
and returned, but they cannot (by default) be compared, so continuing from the above
fragment fred = jane;
is possible (the fields of jane being copied into fred)
but you can't then go on to do
if (fred == jane) cout << "The copying worked ok\n";
- you have to compare field by field.
Classes can contain member functions as well as data. The data can be made private so that other objects can't access it directly.