03.06.2011, 15:23. Просмотров 1041. Ответов 1
Пытаюсь написать программку, но возникла ошибка с выводом информации на экран.
Вот мой код:
C++ |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
| int MAX_ARRAY_SIZE = 2147483647;
template <typename Type1,
typename Type2,
typename Type3>
class SQL {
private:
int iterator;
const int max_arr;
vector<Type1> info1;
vector<Type2> info2;
vector<Type3> info3;
public:
SQL() : iterator(0), max_arr(MAX_ARRAY_SIZE) {}
SQL(int arr) : iterator(0), max_arr(arr) {}
void push_back(Type1 info1_ = NULL, Type2 info2_ = NULL, Type3 info3_ = NULL){
if(iterator) ++iterator;
if(iterator > max_arr) {
string err = "Out of range!";
throw err;
}
info1.push_back(info1_);
info2.push_back(info2_);
info3.push_back(info3_);
}
SQL operator()(const int &i = 0, const int §ion = 0){
if(section < 0 || section > 2) {
string err = "Wrong choosing the section of array!";
throw err;
}
if(i < 0 || i > max_arr) {
string err = "Error in choosing a cell in an array!";
throw err;
}
switch (section){
case 0:
return info1[i];
break;
case 1:
return info2[i];
break;
case 2:
return info3[i];
break;
}
}
};
/////////////////////////////////////////////
////////////////////////////////////////////
////////////////////////////////////////////
namespace _ERROR_ {
class _ERROR {
private:
const string error;
const string close;
public:
_ERROR(const string &err): error(err), close("Press any key to break the programm!") {}
void show_error() {
cout << error << endl;
cout << close << endl;
}
};
}
int main(int argc, char *argv[])
{
wcout.imbue(locale(".866")); //Русская кодировка
system("COLOR 0A");
srand(time(NULL));
for(;;){
try{
SQL<string, int, double> Arr;
Arr.push_back("Hello", 23, 34.53);
cout << Arr(0, 1);
} catch(const string error){
_ERROR_::_ERROR err(error);
err.show_error();
getch();
return 1;
}
}
getch();
return 0;
} |
|
Не работает команда
Error 2 error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'SQL<Type1,Type2,Type3>' (or there is no acceptable conversion)
Я так понимаю, тут необходимо перегрузить оператор вывода, но как я не бился, заставить работать этот код, я не смог.
Помогите пожалуйста, буду благодарен за любые подсказки.