note: the above statements show error as
error: invalid const_cast from type 'std::vector<string, std::allocator<IValue*> > ::const_iterator' to type 'string*'
note:[b] begin( ) is function which returns const_iterator.
note: and also we noticed that for generic type <T> it is accepting. but for specific type <string> it shows error.
We aren't here to write programs for people; we're here to help people write their own programs.
This code makes no sense. What is it supposed to do?
The first function looks like it is supposed to be a template function but I don't see a template. If it is, then yes, synttactically it could be correct. Further semantic checking is done once the template is instantiated. Once the template is instantiated, then yes, it won't compile, because begin() returns an iterator which you are casting to the iterated type. Which makes no sense, but I think you are attempting to cast away the const-ness of the iterator.
Given what the function appears to be doing, why are you passing by const reference and not just reference? This would alleviate the need for const_cast, which IMHO, should rarely be used anyway.
Thank U Jsmith for ur info. actually it is class template. We have define class template at the beginning of the class as"template <class T>".
I have remove that particular const_cast operator. But it shows same error. Even it is not posting different error.
won't work because string does not have an operator-= and even if it did, you would be calling it on a const object and certainly operator-= should be a non-const member function.
Your operator-=() method should not be declared const.