07.01.2010, 21:21. Просмотров 1626. Ответов 7
у меня есть два класса...
один (базовый) читает строку из файла и присваивает её значение переменной этого типа
второй (производный) создаёт массив таких переменных базового типа, заполняя его строчками из файла
но файл почему-то не находит!
почему?
вот прога:
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
| #include <iostream.h>
#include <string.h>
#include <fstream.h>
class base {
char word[9];
public:
char slovo[9];
base();
};
base::base() {
for (int i=0; i<9; i++) {
word[i]=slovo[i];
}
cout<<"vvedite slovo"<<endl;
ifstream fin("input.txt", ios::in|ios::nocreate);
if (!fin) {
cout<<"fail input.txt not found"<<endl;
}
fin>>word;
}
class slovar {
public:
slovar();
base a[4],e[4];
};
slovar::slovar(){
ifstream fin("input.txt", ios::in|ios::nocreate);
if (!fin) {
cout<<"fail input.txt not found"<<endl;
}
for (int i=0; i<4; i++) {
fin>>a[i].slovo;
cout<<a[i].slovo<<endl;
}
}
int main() {
base a1,e1;
slovar a2,e2;
return 0;
} |
|