|
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
************************************************
|