Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <string>
- using namespace std;
- class Student;
- class Grupa {
- string nazwa;
- string kierunek;
- unsigned short semestr;
- Student * studenci;
- public:
- void Zapisz(string a, string b, unsigned short c) {
- nazwa = a;
- kierunek = b;
- semestr = c;
- cout << "\nInformacje o grupie zostaly zapisane.";
- }
- void Wypisz() {
- cout << "\nNazwa grupy: " << nazwa << "\nkierunek: " << kierunek << "\nsemestr: " << semestr;
- }
- Grupa(string a, string b, unsigned short c) : nazwa(a), kierunek(b), semestr(c) {};
- Grupa()
- {
- cout << "Utworzono obiekt, przypisz mu jakies dane!";
- //konstruktor domyslny
- }
- Grupa(const Grupa &obiekt) // konstruktor kopiujacy
- {
- nazwa = obiekt.nazwa;
- kierunek = obiekt.kierunek;
- semestr = obiekt.semestr;
- }
- // metody do zapisywania w polach klasy
- void ZapiszNazwe(string a) { nazwa = a; }
- void ZapiszKierunek(string b) { kierunek = b; }
- void ZapiszSemestr(unsigned short c) { semestr = c; }
- //metody do wypisywania danych z pol obiektu
- string WypiszNazwe() { return nazwa; }
- string WypiszKierunek() { return kierunek; }
- int WypiszSemestr() { return semestr; }
- int maks_studentow;
- Grupa(int a);
- };
- class Student {
- string imie, nazwisko;
- unsigned int numer_indeksu;
- public:
- Student();
- Student(string a, string b, unsigned int c) : imie(a), nazwisko(b), numer_indeksu(c) {};
- };
- int main()
- {
- Grupa *obiekt = new Grupa;
- obiekt->Zapisz("GL03", "IIZ", 3);
- obiekt->Wypisz();
- //przetestowanie metody do wypisywania
- cout << "\n\nTwoj semestr to: " << obiekt->WypiszSemestr();
- delete obiekt;
- return 0;
- }
- Grupa::Grupa(int a)
- {
- maks_studentow = a;
- studenci = new Student [maks_studentow];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement