Advertisement
Bedi97

kolokwium_metody

Dec 12th, 2019
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.20 KB | None | 0 0
  1. // kolos.cpp : Ten plik zawiera funkcję „main”. W nim rozpoczyna się i kończy wykonywanie programu.
  2. //
  3.  
  4. #include <iostream>
  5.  
  6. using namespace std;
  7.  
  8. class Osoba
  9. {
  10.     string _imie, _nazwisko;
  11.     long long _pesel;
  12.  
  13. public:
  14.     Osoba() : _imie("brak"), _nazwisko("brak"), _pesel(0) {}
  15.     Osoba(const string & a1, const string & a2, const long long & a3) : _imie(a1), _nazwisko(a2), _pesel(a3) {}
  16.  
  17.     string & imie() { return _imie; }
  18.     string & nazwisko() { return _nazwisko; }
  19.     long long & pesel() { return _pesel; }
  20.  
  21.     const string & imie() const { return _imie; }
  22.     const string & nazwisko() const { return _nazwisko; }
  23.     const long long & pesel() const { return _pesel; }
  24.  
  25.     friend ostream & operator << (ostream& out, const Osoba& o);
  26.     friend istream & operator >> (istream& in, Osoba& o);
  27. };
  28.  
  29. ostream & operator << (ostream & out, const Osoba & o)
  30. {
  31.     return out << o._imie << o._nazwisko << o._pesel;
  32. }
  33.  
  34. istream & operator >> (istream& in, Osoba& o)
  35. {
  36.     in >> o._imie;
  37.     in >> o._nazwisko;
  38.     in >> o._pesel;
  39.     return in;
  40. }
  41.  
  42. class BazaDanych
  43. {
  44.     Osoba * tab;
  45.  
  46. public:
  47.     BazaDanych() : tab(0) {}
  48.     BazaDanych(int & tab) : tab(tab ? new Osoba[] : 0) {}
  49. };
  50.  
  51.  
  52. int main()
  53. {
  54.     system("pause");
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement