Closed GoogleCodeExporter closed 9 years ago
Не собирается:
list.cpp: In member function ‘TList<T>::TConst_Iterator&
TList<T>::TConst_Iterator::operator=(TList<T>::TConst_Iterator&)’:
list.cpp:38: error: ‘other’ was not declared in this scope
list.cpp: In copy constructor ‘TList<T>::TList(const TList<T>&)’:
list.cpp:104: error: expected `;' before ‘it’
list.cpp:104: error: ‘it’ was not declared in this scope
list.cpp: In member function ‘TList<T>::TIterator
TList<T>::erase(TList<T>::TIterator)’:
list.cpp:262: error: expected `;' before ‘it’
list.cpp:263: error: ‘it’ was not declared in this scope
list.cpp: In member function ‘TList<T>& TList<T>::operator=(TList<T>&)’:
list.cpp:299: error: expected `;' before ‘it’
list.cpp:299: error: ‘it’ was not declared in this scope
list.cpp: In copy constructor ‘TList<T>::TList(const TList<T>&) [with T =
int]’:
list.cpp:319: instantiated from here
list.cpp:104: error: dependent-name ‘TList<T>::TConst_Iterator’ is parsed
as a non-type, but instantiation yields a type
list.cpp:104: note: say ‘typename TList<T>::TConst_Iterator’ if a type is
meant
list.cpp: In member function ‘TList<T>& TList<T>::operator=(TList<T>&) [with
T = int]’:
list.cpp:345: instantiated from here
list.cpp:299: error: dependent-name ‘TList<T>::TIterator’ is parsed as a
non-type, but instantiation yields a type
list.cpp:299: note: say ‘typename TList<T>::TIterator’ if a type is meant
list.cpp: In member function ‘TList<T>::TIterator
TList<T>::erase(TList<T>::TIterator) [with T = int]’:
list.cpp:362: instantiated from here
list.cpp:262: error: dependent-name ‘TList<T>::TIterator’ is parsed as a
non-type, but instantiation yields a type
list.cpp:262: note: say ‘typename TList<T>::TIterator’ if a type is meant
Original comment by aivyu...@gmail.com
on 26 May 2013 at 12:35
Original comment by zhilinskaya.valentina
on 26 May 2013 at 3:25
Original comment by zhilinskaya.valentina
on 26 May 2013 at 3:37
1. Метод getNode у итератора раскрывает
внутреннее устройство класса. К тому же,
позволяет пользователя класса получить
указатель на "внутренности" объекта и
"испортить" его.
2. Должно быть 2 версии back/front. Одна,
константная, возвращает конст ссылку на
объект (или копию, как у Вас). Другая -
неконстантная, позволяющая менять объект.
Пример клиентского кода:
TList<int> a;
...
a.back() = 5;
3. Не вижу тестов на утечки памяти.
Решение не принято.
Original comment by aivyu...@gmail.com
on 26 May 2013 at 7:57
Original comment by zhilinskaya.valentina
on 26 May 2013 at 9:46
0. Warning:
list.cpp:70:16: warning: class 'TList<T>::TIterator' is implicitly friends with
itself [enabled by default]
1. Добавляю в main() код (закоммитил в SVN):
{
TNode<leak> a;
for (int i = 0; i < 10; ++i)
a.push_back(leak());
TNode<leak> b = a;
for (int = 0; i < 10; ++i)
b.push_back(leak());
a.swap(b);
TNode<leak> c;
a = c;
}
Пробую собрать:
list.cpp:70:16: warning: class 'TList<T>::TIterator' is implicitly friends with
itself [enabled by default]
list.cpp: In function 'int main()':
list.cpp:485:19: error: 'class TNode<leak>' has no member named 'push_back'
list.cpp:488:22: error: expected unqualified-id before '=' token
list.cpp:488:22: error: expected ';' before '=' token
list.cpp:488:22: error: expected primary-expression before '=' token
list.cpp:488:27: error: 'i' was not declared in this scope
list.cpp:488:33: error: expected ')' before ';' token
list.cpp:488:37: error: 'i' was not declared in this scope
list.cpp:488:38: error: expected ';' before ')' token
list.cpp:491:15: error: 'class TNode<leak>' has no member named 'swap'
Решение не принято.
Original comment by aivyu...@gmail.com
on 26 May 2013 at 10:10
1. Добавляю в main() код (закоммитил в SVN):
{
TNode<leak> a;
for (int i = 0; i < 10; ++i)
a.push_back(leak());
TNode<leak> b = a;
for (int = 0; i < 10; ++i)
b.push_back(leak());
a.swap(b);
TNode<leak> c;
a = c;
}
А почему должно работать? о_О
Может Вы имели ввиду вместо TNode - TList?
Или я просто не понимаю...
Original comment by zhilinskaya.valentina
on 26 May 2013 at 10:49
Да. Я затупил что-то.
Решение принято.
Оценка: 0.2 балла.
Original comment by aivyu...@gmail.com
on 27 May 2013 at 7:44
Original issue reported on code.google.com by
zhilinskaya.valentina
on 19 May 2013 at 4:40