divyang4481 / mipt-hw

Automatically exported from code.google.com/p/mipt-hw
0 stars 0 forks source link

task11 TRBTree (Яковенко) #239

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
iakovenko_pavel/task11_TRBTree

Original issue reported on code.google.com by iakovenk...@gmail.com on 9 May 2013 at 12:38

GoogleCodeExporter commented 9 years ago
Не собирается:
In file included from ./main.cpp:5:
./my_set.h: In member function ‘TRBTree<T>::TNode& 
TRBTree<T>::TNode::operator=(TRBTree<T>::TNode&)’:
./my_set.h:25: error: ‘friend’ used outside of class
./my_set.h: In member function ‘TRBTree<T>::iterator 
TRBTree<T>::iterator::operator--()’:
./my_set.h:274: error: expected `;' before ‘}’ token
./my_set.h: In member function ‘TRBTree<T>& TRBTree<T>::operator=(const 
TRBTree<T>&)’:
./my_set.h:340: error: expected `;' before ‘pos’
./my_set.h:340: error: ‘pos’ was not declared in this scope
./main.cpp: In function ‘void Test3()’:
./main.cpp:67: error: no match for ‘operator!=’ in ‘pos != tree1. 
TRBTree<T>::end [with T = TFoo]()’
./my_set.h:293: note: candidates are: bool 
TRBTree<T>::iterator::operator!=(TRBTree<T>::iterator&) [with T = TFoo]
./main.cpp:71: error: no match for ‘operator=’ in ‘found = tree1. 
TRBTree<T>::find [with T = TFoo](TFoo(((const TFoo&)((const TFoo*)(& a)))))’
./my_set.h:296: note: candidates are: TRBTree<T>::iterator 
TRBTree<T>::iterator::operator=(TRBTree<T>::iterator&) [with T = TFoo]
./main.cpp:77: error: no match for ‘operator!=’ in ‘pos != tree1. 
TRBTree<T>::end [with T = TFoo]()’
./my_set.h:293: note: candidates are: bool 
TRBTree<T>::iterator::operator!=(TRBTree<T>::iterator&) [with T = TFoo]
./main.cpp:88: error: no match for ‘operator!=’ in ‘pos != tree2. 
TRBTree<T>::end [with T = TFoo]()’
./my_set.h:293: note: candidates are: bool 
TRBTree<T>::iterator::operator!=(TRBTree<T>::iterator&) [with T = TFoo]
./main.cpp:94: error: no match for ‘operator!=’ in ‘pos != tree1. 
TRBTree<T>::end [with T = TFoo]()’
./my_set.h:293: note: candidates are: bool 
TRBTree<T>::iterator::operator!=(TRBTree<T>::iterator&) [with T = TFoo]
./main.cpp:97: error: no match for ‘operator!=’ in ‘pos != tree2. 
TRBTree<T>::end [with T = TFoo]()’
./my_set.h:293: note: candidates are: bool 
TRBTree<T>::iterator::operator!=(TRBTree<T>::iterator&) [with T = TFoo]
./main.cpp:103: error: no match for ‘operator!=’ in ‘pos != tree1. 
TRBTree<T>::end [with T = TFoo]()’
./my_set.h:293: note: candidates are: bool 
TRBTree<T>::iterator::operator!=(TRBTree<T>::iterator&) [with T = TFoo]
./my_set.h: In member function ‘TRBTree<T>& TRBTree<T>::operator=(const 
TRBTree<T>&) [with T = TFoo]’:
./main.cpp:101:   instantiated from here
./my_set.h:340: error: dependent-name ‘TRBTree<T>::iterator’ is parsed as a 
non-type, but instantiation yields a type
./my_set.h:340: note: say ‘typename TRBTree<T>::iterator’ if a type is meant
./my_set.h: In constructor ‘TRBTree<T>::TNode::TNode() [with T = TFoo]’:
./my_set.h:323:   instantiated from ‘TRBTree<T>::TRBTree() [with T = TFoo]’
./main.cpp:48:   instantiated from here
./my_set.h:15: warning: ‘TRBTree<TFoo>::TNode::right’ will be initialized 
after
./my_set.h:13: warning:   ‘TRBTree<TFoo>::TNode* 
TRBTree<TFoo>::TNode::parent’
./my_set.h:8: warning:   when initialized here

Original comment by aivyu...@gmail.com on 11 May 2013 at 5:41

GoogleCodeExporter commented 9 years ago

Original comment by iakovenk...@gmail.com on 21 May 2013 at 5:42

GoogleCodeExporter commented 9 years ago
0. Warnings:
In file included from main.cpp:6:0:
my_set.h: In instantiation of 'TRBTree<T>::TNode::TNode() [with T = TFoo]':
my_set.h:385:3:   required from 'TRBTree<T>::TRBTree() [with T = TFoo]'
main.cpp:49:16:   required from here
my_set.h:15:10: warning: 'TRBTree<TFoo>::TNode::right' will be initialized 
after [-Wreorder]
my_set.h:13:10: warning:   'TRBTree<TFoo>::TNode* TRBTree<TFoo>::TNode::parent' 
[-Wreorder]
my_set.h:8:3: warning:   when initialized here [-Wreorder]

1. Пишу свой тест:
static void Test4() {
    typedef TRBTree<TFoo> TTreeFoo;

    TTreeFoo a;
    for (int i = 0; i < 100; ++i)
        a.insert(TFoo(i));

    for (int i = 0; i < 100; ++i)
        TTreeFoo::iterator iter = a.find(TFoo(i));

    TTreeFoo b = a;

    a.swap(b);
}
Он приводит к проезду по памяти и падению 
программы. Код закоммитил.

Решение не принято.

Original comment by aivyu...@gmail.com on 26 May 2013 at 12:16

GoogleCodeExporter commented 9 years ago
Юлий Романович,
я проверил в visual studio и с помощью MinGW 4.7.2, у 
меня варнингов не было.

Original comment by iakovenk...@gmail.com on 26 May 2013 at 1:38

GoogleCodeExporter commented 9 years ago
При сборке нужно ставить максимальный 
уровень предупреждений.
Я делаю это так:
g++ -Wall main.cpp

Original comment by aivyu...@gmail.com on 26 May 2013 at 2:29

GoogleCodeExporter commented 9 years ago
Решение принято.

Original comment by aivyu...@gmail.com on 26 May 2013 at 2:30