|
|
Регистрация Восстановить пароль |
Повторная активизация e-mail |
Регистрация | Задать вопрос |
Заплачу за решение |
Новые сообщения |
Сообщения за день |
Расширенный поиск |
Правила |
Всё прочитано |
|
Опции темы | Поиск в этой теме |
19.11.2012, 21:21 | #1 |
Новичок
Джуниор
Регистрация: 17.11.2012
Сообщений: 2
|
Перегрузка
#include "stdafx.h"
#include "iostream" #include "fstream" #include "string" #include "math.h" using namespace std; class Student { private: friend istream & operator>>(istream&input, Student&ST) { cout<<"Please enter data about Student"<<endl<<"Name: "; input>>ST.Name; cout<<"Surname: "<<endl; input>>ST.SName; cout<<"Cours: "<<endl; input>>ST.Cours; cout<<"Student card: "<<endl; input>>ST.Studcrd; cout<<"Grant: "<<endl; input>>ST.Grant; return input; } friend ostream & operator<<(ostream&output,Student&S t) { output<<"Information about a student"<<endl<<"Name: "<<St.Name<<endl<<"Surname: "<<St.SName<<endl<<"Cours: "<<St.Cours<<endl<<"Student card: "<<St.Studcrd<<endl<<"Grant: "<<St.Grant<<endl; return output; } friend ofstream & operator<<(ofstream&output,Student& sT) { output<<sT.Name<<endl<<sT.SName<<en dl<<sT.Cours<<endl<<sT.Studcrd<<end l<<sT.Grant<<endl; return output; } friend ifstream & operator>>(ifstream&input,Student&s t) { input>>st.Name>>st.SName>>st.Cours> >st.Studcrd>>st.Grant; return input; } public: string Name; string SName; int Cours; string Studcrd; int Grant; Student () { } Student (string Nm, string SN, int Cr, string Sc, int Gr) { Name=Nm; SName=SN; Cours=Cr; Studcrd=Sc; Grant=Gr; } }; int _tmain(int argc, _TCHAR* argv[]) { Student mas[5]; for (int i=0;i<5;i++) { cin>>mas[i]; } ofstream f; f.open("D:\\CSF 205\\Sawa.txt", ios:ut); for (int j=0;j<5;j++) { f<<mas[j]; } f.close(); Student msa[5]; ifstream d; d.open("D:\\CSF 205\\Sawa.txt", ios::in); for (int e=0;e<5;e++) { d>>msa[e]; } int counT=0; for (int t=0;t<5;t++) { if (msa[t].Cours == 4) if (msa[t].Grant == '0') counT++; } for (int k=0;k<5;k++) { cout<<msa[k]; } cout<<"Count of students whith study on 4 cours and don't have a grant: "<<counT<<endl; return 0; // getch(); } Последний раз редактировалось MoNsTeRmEn; 20.11.2012 в 19:20. |
20.11.2012, 10:13 | #2 |
Форумчанин
Регистрация: 17.12.2011
Сообщений: 111
|
|
20.11.2012, 10:43 | #3 |
Форумчанин
Регистрация: 17.12.2011
Сообщений: 111
|
Зачем же удалять код, если не удаляете всё сообщение в целом?
Вполне возможно, что ваш код когда-нибудь кому-нибудь поможет. |
Похожие темы | ||||
Тема | Автор | Раздел | Ответов | Последнее сообщение |
[C++]перегрузка | Nadinka______ | Помощь студентам | 3 | 13.09.2011 19:16 |
Перегрузка [] | Lazy maximka | Помощь студентам | 8 | 02.05.2011 10:43 |
C++ Перегрузка | GLAM1 | Помощь студентам | 3 | 31.03.2011 21:09 |
Перегрузка + | Blad47 | Помощь студентам | 4 | 21.03.2011 01:49 |
Перегрузка ++ | counter | Общие вопросы C/C++ | 3 | 20.12.2008 13:30 |