You are trying to say work is an array. Inside this array, there are three elements referenced by name. Each element contain an entry.
In C++ array which reference it's element by index are usually called array or vector or queue, deque etc. Array which reference it's element by name are usually called map, multimap etc.
Actually PHP was created long after C++ exist so a lot of features C++ have it and PHP just copy the concept over.
What I don't like about PHP is they don't differentiate reference using index or name. E.g
work[0] is array which reference it's element by index. work['name'] which reference it's element by name. The syntax is too "small" for one to notice work is what variable datatype.
In this aspect, Perl is better. @work indicate array which reference it's element by index. %work indicate hash aka associative array which reference it's elements by name.
Hi Carlsum1986,
If I am not mistaken, you would like to define several elements of type "work" each having a name, office and home element, right? If that is the case, a map or multimap would not be an ideal C++ type. I would suggest you to declare a class type or a struct type to encapsulate the work elements and then create a vector of those work elements like the following.
On the other hand, if you just want to associate few keywords with values, sohguanh is right & you should use either a map or multimap (if you want to associate different values with the same keyword).