Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- using namespace std;
- class Student
- {
- friend ostream& operator<<(ostream&, const Student&);
- friend istream& operator>>(istream&, Student&);
- string Imie;
- string Nazwisko;
- public:
- Student();
- Student(string, string);
- void usun_opis();
- };
- ostream& operator<<(ostream& os, const Student& student)
- {
- os << student.Imie << ' ' << student.Nazwisko;
- return os;
- }
- istream& operator>>(istream& is, Student& student)
- {
- is >> student.Imie >> student.Nazwisko;
- return is;
- }
- Student::Student() {}
- Student::Student(string name, string scnd_name) : Imie(name), Nazwisko(scnd_name) {}
- void Student::usun_opis()
- {
- Imie = "";
- Nazwisko = "";
- }
- int main()
- {
- unsigned ilu = 0;
- Student tab[100];
- char komenda;
- unsigned nr;
- do
- {
- komenda = _getch();
- komenda = toupper(komenda);
- switch(komenda)
- {
- case 'N':
- cout << "Podaj imie i nazwisko studenta: ";
- cin >> tab[ilu];
- ++ilu;
- break;
- case 'W':
- for(unsigned i = 0; i < ilu; ++i)
- cout << tab[i] << endl;
- break;
- case 'U':
- cout << "Podaj nr studenta, ktorego chcesz usunac: ";
- cin >> nr;
- tab[nr].usun_opis();
- for(unsigned i = nr; i < ilu; ++i)
- tab[i] = tab[i + 1];
- --ilu;
- tab[ilu].usun_opis();
- }
- } while(komenda != 'Q');
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement