Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.74 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <string>
  4. using namespace std;
  5.  
  6. class Student;
  7.  
  8. class Grupa {
  9.     string nazwa;
  10.     string kierunek;
  11.     unsigned short semestr;
  12.     Student * studenci;
  13.  
  14. public:
  15.     void Zapisz(string a, string b, unsigned short c) {
  16.         nazwa = a;
  17.         kierunek = b;
  18.         semestr = c;
  19.         cout << "\nInformacje o grupie zostaly zapisane.";
  20.     }
  21.  
  22.     void Wypisz() {
  23.         cout << "\nNazwa grupy: " << nazwa << "\nkierunek: " << kierunek << "\nsemestr: " << semestr;
  24.     }
  25.  
  26.     Grupa(string a, string b, unsigned short c) : nazwa(a), kierunek(b), semestr(c) {};
  27.  
  28.     Grupa()
  29.     {
  30.         cout << "Utworzono obiekt, przypisz mu jakies dane!";
  31.         //konstruktor domyslny
  32.     }
  33.  
  34.     Grupa(const Grupa &obiekt) // konstruktor kopiujacy
  35.     {
  36.         nazwa = obiekt.nazwa;
  37.         kierunek = obiekt.kierunek;
  38.         semestr = obiekt.semestr;
  39.     }
  40.  
  41.     // metody do zapisywania w polach klasy
  42.     void ZapiszNazwe(string a) { nazwa = a; }
  43.     void ZapiszKierunek(string b) { kierunek = b; }
  44.     void ZapiszSemestr(unsigned short c) { semestr = c; }
  45.  
  46.     //metody do wypisywania danych z pol obiektu
  47.     string WypiszNazwe() { return nazwa; }
  48.     string WypiszKierunek() { return kierunek; }
  49.     int WypiszSemestr() { return semestr; }
  50.  
  51.     int maks_studentow;
  52.     Grupa(int a);
  53. };
  54.  
  55.  
  56. class Student {
  57.     string imie, nazwisko;
  58.     unsigned int numer_indeksu;
  59. public:
  60.     Student();
  61.     Student(string a, string b, unsigned int c) : imie(a), nazwisko(b), numer_indeksu(c) {};
  62. };
  63.  
  64. int main()
  65. {
  66.     Grupa *obiekt = new Grupa;
  67.     obiekt->Zapisz("GL03", "IIZ", 3);
  68.     obiekt->Wypisz();
  69.  
  70.     //przetestowanie metody do wypisywania
  71.     cout << "\n\nTwoj semestr to: " << obiekt->WypiszSemestr();
  72.     delete obiekt;
  73.  
  74.     return 0;
  75. }
  76.  
  77. Grupa::Grupa(int a)
  78. {
  79.     maks_studentow = a;
  80.     studenci = new Student [maks_studentow];
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement