0
votes
class FileObject
{
public:
set<string> owners;
.
.
.
};

in this function I have problem with this line:for(std::set it = owners.begin(); it != owners.end(); it++).

void FileObject::viewFileDetails(string* messageToPrint)
{
    *messageToPrint = fileName;
    *messageToPrint += ", ";
    if(status == 0)
    {
        *messageToPrint += convertInt(countVersion);
    }
    else
    {
        *messageToPrint += userCheckedOut;
    }
    *messageToPrint += " (owners: ";
    unsigned int i=0;

    for(std::set<string> it = owners.begin(); it != owners.end(); it++)
    {
        *messageToPrint += *it;
        if( i != owners.size())
        {
            *messageToPrint += ", ";
        }
        else
        {
            *messageToPrint += ")";
        }
        i++;
    }

}

this is the error:

Multiple markers at this line - 'std::set >' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' - no 'operator++(int)' declared for postfix '++' [-fpermissive] - 'std::set >' is not derived from 'const std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>' - 'std::set >' is not derived from 'const std::vector<_Tp, _Alloc>' - 'std::set >' is not derived from 'const std::_Rb_tree_iterator<_Tp>' - 'std::set >' is not derived from 'const std::list<_Tp, _Alloc>' - 'std::set >' is not derived from 'const std::_List_iterator<_Tp>' - 'std::set >' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' - 'std::set >' is not derived from 'const __gnu_cxx::new_allocator<_Tp>' - 'std::set >' is not derived from 'const std::multiset<_Key, _Compare, _Alloc>' - 'std::set >' is not derived from 'const std::istream_iterator<_Tp, _CharT, _Traits, _Dist>' - 'std::set >::iterator {aka std::_Rb_tree_const_iterator >}' is not derived from 'const std::set<_Key, _Compare, _Alloc>' - 'std::set >' is not derived from 'const std::reverse_iterator<_Iterator>' - 'std::set >' is not derived from 'const std::pair<_T1, _T2>' - 'std::set >' is not derived from 'const std::fpos<_StateT>' - candidates are: - conversion from 'std::set >::iterator {aka std::_Rb_tree_const_iterator >}' to non-scalar type 'std::set >' requested - no match for 'operator!=' (operand types are 'std::set >' and 'std::set >::iterator {aka std::_Rb_tree_const_iterator >}') - 'std::set >' is not derived from 'const std::istreambuf_iterator<_CharT, _Traits>' - mismatched types 'const _CharT*' and 'std::set >' - 'std::set >' is not derived from 'const std::basic_string<_CharT, _Traits, _Alloc>' - 'std::set >' is not derived from 'const std::allocator<_CharT>'

1

1 Answers

0
votes

The type of it should be set<string>::const_iterator or set<string>::iterator, not set<string>.

If you're using C++11, you can just use auto. :-)

Also, as a matter of style, prefer to return your messageToPrint by value, rather than using an out parameter.