cpp:stl:map

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
cpp:stl:map [2020/05/31 08:23]
gthanos
cpp:stl:map [2020/05/31 08:30]
gthanos [H συνάρτηση operator[]]
Line 100: Line 100:
 ==== H συνάρτηση operator[] ==== ==== H συνάρτηση operator[] ====
  
-Η συνάρτηση [[http://www.cplusplus.com/reference/map/map/operator[]/operator[] ]] έχει διπλό ρόλο //α)// να επιστρέψει την τιμή ενός κλειδιού που είναι αποθηκευμένο στο //std::map// ή //std::multimap// και //β)// να θέσει την τιμή ενός κλειδιού που είναι ή δεν είναι αποθηκευμένο sto //std::map//, //std::multimap//.+Η συνάρτηση [[http://www.cplusplus.com/reference/map/map/operator[]operator[] ]] έχει διπλό ρόλο //α)// να επιστρέψει την τιμή ενός κλειδιού που είναι αποθηκευμένο στο //std::map// ή //std::multimap// και //β)// να θέσει την τιμή ενός κλειδιού που είναι ή δεν είναι αποθηκευμένο sto //std::map//, //std::multimap//.
  
 === Παράδειγμα 1ο - Ανάγνωση με χρήση του operator [] === === Παράδειγμα 1ο - Ανάγνωση με χρήση του operator [] ===
Line 124: Line 124:
   std::string address_mm = students[ Student("Minie Mouse", 1240) ];   // address_mm does not exist   std::string address_mm = students[ Student("Minie Mouse", 1240) ];   // address_mm does not exist
      
-  std::cout << "Peter Pan aem: " << aem_pp << std::endl; +  std::cout << "Peter Pan   address: " << address_pp << std::endl; 
-  std::cout << "Minie Mouse aem: " << aem_mm << std::endl;             // empty string+  std::cout << "Minie Mouse address: " << address_mm << std::endl;             // empty string
 } }
 </code> </code>
cpp/stl/map.txt · Last modified: 2020/06/01 06:13 (external edit)