Array Of Class Objects

A class may have a member that is array and contains class instances.




  • At line 22 an empty array is declared.
  • At lines 46 - 48 elements are added to the array. This can be done also via the function array_push.
  • At lines 52 and 60 all elements of the array are looped.
  • At lines 26 - 35 the array is sorted ascending by price. If at line 27 the sign < is replaced with >, then the sorting would be descending.