Skip to content

Your own types

Read · 1 of 3

A struct bundles values together

A student has a name and marks. Instead of two separate vectors, make one type: struct Student { string name; int marks; }; (note the ; after the brace).

Each Student has its own name and marks, reached with a dot: s.name, s.marks.