Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > С/С++: Кроссплатформенное программирование, Qt/Gtk+/wxWidgets > Проблема с qSort


Автор: zaytsewa 19.7.2010, 11:49
Жду советов и предложений)

Код

namespace SpSchedule {
    class Schedule {

        public :
            bool create( const ScheduleInfo& schedInfo );
        private:
            QList< SpSatellite::Schedule > m_list;
...
}}


Код

namespace SpSatellite {
  struct Schedule {
    bool operator <(const Schedule& s) {
      return (aos.secsTo(s.aos) > 0);
    };
...
}}



/usr/include/qt4/QtCore/qalgorithms.h: In member function 'bool qLess<T>::operator()(const T&, const T&) const [with T = SpSatellite::Schedule]':
/usr/include/qt4/QtCore/qalgorithms.h:351:   instantiated from 'void QAlgorithmsPrivate::qSortHelper(RandomAccessIterator, RandomAccessIterator, const T&, LessThan) [with RandomAccessIterator = QList<SpSatellite::Schedule>::iterator, T = SpSatellite::Schedule, LessThan = qLess<SpSatellite::Schedule>]'
/usr/include/qt4/QtCore/qalgorithms.h:395:   instantiated from 'void QAlgorithmsPrivate::qSortHelper(RandomAccessIterator, RandomAccessIterator, const T&) [with RandomAccessIterator = QList<SpSatellite::Schedule>::iterator, T = SpSatellite::Schedule]'
/usr/include/qt4/QtCore/qalgorithms.h:180:   instantiated from 'void qSort(RandomAccessIterator, RandomAccessIterator) [with RandomAccessIterator = QList<SpSatellite::Schedule>::iterator]'
schedule.cpp:64:   instantiated from here
/usr/include/qt4/QtCore/qalgorithms.h:161: error: passing 'const SpSatellite::Schedule' as 'this' argument of 'bool SpSatellite::Schedule::operator<(const SpSatellite::Schedule&)' discards qualifiers


вот так он ругается на

bool Schedule::create( const ScheduleInfo& schedInfo ) {
...
 qSort( m_list.begin(),m_list.end() );
...
}

Автор: djamshud 19.7.2010, 11:57
Код

bool operator <(const Schedule& s) -->>const<<--


?

Автор: zaytsewa 19.7.2010, 13:04
проблема решена. спасибо)

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)