Salve a tutti,
ho il seguente metodo di una classe:
nella seguente riga fa riferimento alla struct mypair:codice:template<class K, class E> void hash_table<K,E>::insert(const mypair<const K, E>& the_pair) { // search the table for a matching element int b = search(the_pair.first); // chack if matching element found if (table[b] == NULL){ // no matching element and table not full table[b] = new mypair< const K, E > (the_pair); dsize++; } else { // check id duplicate or table full if (table[b]->first == the_pair.first) // duplicate, change table[b]->second table[b]->second = the_pair.second; else{ // table is full // throw the exception hash_table_full(); } } }
La struttura è la seguente:codice:table[b] = new mypair< const K, E > (the_pair)
Il compilatore però mi da errore dicendomi:codice:template<class K, class E> struct mypair { // data member K first; E second; // methods mypair(){} mypair(mypair<const K,E>& the_pair){ first = the_pair.first; second = the_pair.second; } };
Non riesco a capire cos'è che no gli va a genio. Ho provato anche a cambiare la riga incriminata del metodo in:codice:Type no matching function for call to 'mypair<const std::basic_string<char>, std::basic_string<char> >::mypair(const mypair<const std::basic_string<char>, std::basic_string<char> >&)' hash_table.h /Dizionari_2 line 184 C/C++ Problem
Ma nulla, da sempre lo stesso errore. Sapreste dirmi in cosa sbaglio? perchè ci sto impazzendo da ore.codice:table[b] = new mypair< const K, E > (& the_pair)
Vi ringrazio in anticipo,
Neptune.


Rispondi quotando