Essays.club - Получите бесплатные рефераты, курсовые работы и научные статьи
Поиск

Потоки. Файлы

Автор:   •  Декабрь 10, 2018  •  Лабораторная работа  •  2,163 Слов (9 Страниц)  •  302 Просмотры

Страница 1 из 9

Министерство образования Республики Беларусь

«Белорусский государственный

университет информатики и радиоэлектроники»

Лабораторная работа №3

на тему:

«Потоки. Файлы»

   

Выполнил:

студент гр.

Car:

ifstream& operator >>(ifstream& in, Car& ob)

         {

                 in >> dynamic_cast<Color&>(ob);

                 in >> dynamic_cast<Body&>(ob);

                 in >> dynamic_cast<Engine&>(ob);

                 if (!in)

                         return in;

                 in.getline(ob.carbrand, 20, '|');

                 in.getline(ob.carmodel, 20, '|');

                 in >> ob.carprice;

                 in.getline(ob.carproducer, 20, '|');

                 cout << "Я работаю !!!";

                 system("pause");

                 return in;

         }

ofstream& operator <<(ofstream& fout, Car& ob) // перегрузка ввода в файл

 {

         fout << ob.color << '|' << ob.ID << ' ' << ob.lengh << ' ' << ob.high << ' ' << ob.massa << ' ' << ob.typeOfEngine << '|' << ob.horsepower << ' ' << ob.carbrand

                 << '|' << ob.carmodel << '|' << ob.carprice << ' ' << ob.carproducer << '|';

         return fout;

 }

Color:

ifstream& operator >>(ifstream& in, Color& ob)

{

        in.getline(ob.color, 30, '|');

        in >> ob.ID;

        return in;

}

ofstream& operator <<(ofstream& out, Color& ob) //ввод в файл

{

        out << ob.color << ' ' << ob.ID<<' ';

        return out;

}

Body:

ifstream& operator >>(ifstream& in, Body& ob) // вывод в файл

{

        in >> ob.lengh;

        in >> ob.lengh;

        in >> ob.massa;

        return in;

}

ofstream& operator <<(ofstream& out, Body& ob) //ввод в файл

{

        out << ob.lengh << ' ' << ob.high << ' '<<ob.massa<<' ';

        return out;

}

Engine:

ifstream& operator >>(ifstream& in, Engine& ob) // вывод в файл

{

        in.getline(ob.typeOfEngine, 20, '|');

        in >> ob.horsepower;

        return in;

}

ofstream& operator <<(ofstream& out, Engine& ob) //ввод в файл

{

        out << ob.typeOfEngine<< ' ' << ob.horsepower;

        return out;

}

Menu:

while (u == 0)

        {

                system("cls");

                cout << "1-Добавить элемент стека" << endl

                        << "2-Извлечь элемент стека" << endl

                        << "3-Вывести все элементы стека " << endl

...

Скачать:   txt (5.3 Kb)   pdf (238.8 Kb)   docx (14.3 Kb)  
Продолжить читать еще 8 страниц(ы) »
Доступно только на Essays.club