Thread: [Dev-C++] Vector and algorithms
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Alessandro B. <ale...@is...> - 2007-11-12 22:59:09
|
Hello, I wrote this method and I receive an error message in compilation:
bool Dizionario::inDictionary(const string &a) const
{
vector<string>::iterator result =
find( elenco.begin(), elenco.end(), a );
if (result == elenco.end()) return false;
return true;
}
598 C:\Programmi\Dev-Cpp\include\c++\3.3.1\bits\stl_iterator.h invalid
conversion from `const std::string* const' to `std::string*'
I wonder the problem is in elenco.begin() and elenco.end() and the const
method (if I erase the keyword const the program is OK, but I don't want
remove const because the method is const).
Have I cast elenco.begin() and elenco.end()? In which mode?
Thanks
Alessandro
--
************************************************
Prof. Alessandro Bugatti
Docente di Informatica
Istituto Tecnico Industriale Statale B. Castelli
E-mail: ale...@is...
Sito web: www.imparando.net
************************************************
|
|
From: Per W. <pw...@ia...> - 2007-11-12 23:30:36
|
Don't you think it would help if your mail also contains the
declaration for elenco?
/pwm
On Mon, 12 Nov 2007, Alessandro Bugatti wrote:
> Hello, I wrote this method and I receive an error message in compilation:
>
> bool Dizionario::inDictionary(const string &a) const
> {
> vector<string>::iterator result =
> find( elenco.begin(), elenco.end(), a );
> if (result == elenco.end()) return false;
> return true;
> }
>
> 598 C:\Programmi\Dev-Cpp\include\c++\3.3.1\bits\stl_iterator.h invalid
> conversion from `const std::string* const' to `std::string*'
>
> I wonder the problem is in elenco.begin() and elenco.end() and the const
> method (if I erase the keyword const the program is OK, but I don't want
> remove const because the method is const).
> Have I cast elenco.begin() and elenco.end()? In which mode?
> Thanks
> Alessandro
>
> --
> ************************************************
> Prof. Alessandro Bugatti
> Docente di Informatica
> Istituto Tecnico Industriale Statale B. Castelli
> E-mail: ale...@is...
> Sito web: www.imparando.net
> ************************************************
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems? Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|
|
From: Per W. <pw...@ia...> - 2007-11-12 23:43:15
|
Anyway, it is a common problem with C++ and const methods EMA System email: pw...@ia... Per Westermark web: http://iapetus.neab.net Vargvaegen 174B phone: +46 70 214 74 48 S-906 42 Umeaa Sweden On Tue, 13 Nov 2007, Per Westermark wrote: > Don't you think it would help if your mail also contains the > declaration for elenco? > > /pwm > > On Mon, 12 Nov 2007, Alessandro Bugatti wrote: > > > Hello, I wrote this method and I receive an error message in compilation: > > > > bool Dizionario::inDictionary(const string &a) const > > { > > vector<string>::iterator result = > > find( elenco.begin(), elenco.end(), a ); > > if (result == elenco.end()) return false; > > return true; > > } > > > > 598 C:\Programmi\Dev-Cpp\include\c++\3.3.1\bits\stl_iterator.h invalid > > conversion from `const std::string* const' to `std::string*' > > > > I wonder the problem is in elenco.begin() and elenco.end() and the const > > method (if I erase the keyword const the program is OK, but I don't want > > remove const because the method is const). > > Have I cast elenco.begin() and elenco.end()? In which mode? > > Thanks > > Alessandro > > > > -- > > ************************************************ > > Prof. Alessandro Bugatti > > Docente di Informatica > > Istituto Tecnico Industriale Statale B. Castelli > > E-mail: ale...@is... > > Sito web: www.imparando.net > > ************************************************ > > > > > > ------------------------------------------------------------------------- > > This SF.net email is sponsored by: Splunk Inc. > > Still grepping through log files to find problems? Stop. > > Now Search log events and configuration files using AJAX and a browser. > > Download your FREE copy of Splunk now >> http://get.splunk.com/ > > _______________________________________________ > > Dev-cpp-users mailing list > > Dev...@li... > > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
|
From: Alessandro B. <ale...@is...> - 2007-11-13 16:14:07
|
Sorry,
vector <string> elenco;
Alessandro
Per Westermark ha scritto:
> Don't you think it would help if your mail also contains the
> declaration for elenco?
>
> /pwm
>
> On Mon, 12 Nov 2007, Alessandro Bugatti wrote:
>
>
>> Hello, I wrote this method and I receive an error message in compilation:
>>
>> bool Dizionario::inDictionary(const string &a) const
>> {
>> vector<string>::iterator result =
>> find( elenco.begin(), elenco.end(), a );
>> if (result == elenco.end()) return false;
>> return true;
>> }
>>
>> 598 C:\Programmi\Dev-Cpp\include\c++\3.3.1\bits\stl_iterator.h invalid
>> conversion from `const std::string* const' to `std::string*'
>>
>> I wonder the problem is in elenco.begin() and elenco.end() and the const
>> method (if I erase the keyword const the program is OK, but I don't want
>> remove const because the method is const).
>> Have I cast elenco.begin() and elenco.end()? In which mode?
>> Thanks
>> Alessandro
>>
>> --
>> ************************************************
>> Prof. Alessandro Bugatti
>> Docente di Informatica
>> Istituto Tecnico Industriale Statale B. Castelli
>> E-mail: ale...@is...
>> Sito web: www.imparando.net
>> ************************************************
>>
>>
>> -------------------------------------------------------------------------
>> This SF.net email is sponsored by: Splunk Inc.
>> Still grepping through log files to find problems? Stop.
>> Now Search log events and configuration files using AJAX and a browser.
>> Download your FREE copy of Splunk now >> http://get.splunk.com/
>> _______________________________________________
>> Dev-cpp-users mailing list
>> Dev...@li...
>> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
>> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>>
>>
>
>
>
>
--
************************************************
Prof. Alessandro Bugatti
Docente di Informatica
Istituto Tecnico Industriale Statale B. Castelli
E-mail: ale...@is...
Sito web: www.imparando.net
************************************************
|
|
From: Alessandro B. <ale...@is...> - 2007-11-13 16:16:43
|
Thanks, now it works.
Alessandro.
Wobien Doyer ha scritto:
> Hello Alessandro,
> I had problems like that with iterators in const methods.
> It was solved by using const_iterator instead, so:
>
> vector<string>::const_iterator result =
> find( elenco.begin(), elenco.end(), a );
>
> The strings in the vector are, inside a const method considered to be
> const, but a non const iterator points to a non const string.
>
>
> Wobien
>
> ----- Original Message ----- From: "Alessandro Bugatti"
> <ale...@is...>
> To: <dev...@li...>
> Sent: Monday, November 12, 2007 11:59 PM
> Subject: [Dev-C++] Vector and algorithms
>
>
>> Hello, I wrote this method and I receive an error message in
>> compilation:
>>
>> bool Dizionario::inDictionary(const string &a) const
>> {
>> vector<string>::iterator result =
>> find( elenco.begin(), elenco.end(), a );
>> if (result == elenco.end()) return false;
>> return true;
>> }
>>
>> 598 C:\Programmi\Dev-Cpp\include\c++\3.3.1\bits\stl_iterator.h invalid
>> conversion from `const std::string* const' to `std::string*'
>>
>> I wonder the problem is in elenco.begin() and elenco.end() and the const
>> method (if I erase the keyword const the program is OK, but I don't want
>> remove const because the method is const).
>> Have I cast elenco.begin() and elenco.end()? In which mode?
>> Thanks
>> Alessandro
>>
>> --
>> ************************************************
>> Prof. Alessandro Bugatti
>> Docente di Informatica
>> Istituto Tecnico Industriale Statale B. Castelli
>> E-mail: ale...@is...
>> Sito web: www.imparando.net
>> ************************************************
>>
>>
>> -------------------------------------------------------------------------
>>
>> This SF.net email is sponsored by: Splunk Inc.
>> Still grepping through log files to find problems? Stop.
>> Now Search log events and configuration files using AJAX and a browser.
>> Download your FREE copy of Splunk now >> http://get.splunk.com/
>> _______________________________________________
>> Dev-cpp-users mailing list
>> Dev...@li...
>> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
>> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
>
>
--
************************************************
Prof. Alessandro Bugatti
Docente di Informatica
Istituto Tecnico Industriale Statale B. Castelli
E-mail: ale...@is...
Sito web: www.imparando.net
************************************************
|