Salve,
in perl ero abituato a trattare gli hash in questo modo:
in che modo C++ gestisce gli array associativi?codice:my %hash; $hash{"key"} = "value";
grazie
Salve,
in perl ero abituato a trattare gli hash in questo modo:
in che modo C++ gestisce gli array associativi?codice:my %hash; $hash{"key"} = "value";
grazie
Alla batteria dai retta ballA
No MP tecnici (non rispondo nemmeno!), usa il forum.
ad esempio basta un codice del genere per creare array assiociativi basasi su key, value (entrambi string)??
cambia molto se durante la insert uso pair o make_pair?codice:#include <string> #include <iostream> #include <map> #include <utility> using namespace std; int main() { map<string, string> hash; hash["nome"] = "mio nome"; hash.insert(pair<string, string>("cognome", "mio cognome")); cout << hash["nome"] << endl; cout << hash["cognome"] << endl; return 0; }
grazie
Alla batteria dai retta ballA
Il vantaggio di usare make_pair è solo che deduce da sola gli argomenti con cui costruire la pair che poi restituisce. Un aiuto in più che non guasta.
This code and information is provided "as is" without warranty of any kind, either expressed
or implied, including but not limited to the implied warranties of merchantability and/or
fitness for a particular purpose.