Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Zad 16
- #include <iostream>
- #include <cstdlib>
- using namespace std;
- class Osoba{
- private:
- int rok;
- string * nazwisko;
- public:
- Osoba(){
- *nazwisko = "";
- rok = 2000;
- }
- Osoba(int r, char * nzw){
- ustawRok(r);
- ustawNazwisko(nzw);
- }
- ~Osoba(){
- delete nazwisko;
- }
- void ustawRok(int r){
- if(r > 1990 && r < 2018) rok = r;
- }
- int zwrocRok(){
- return rok;
- }
- void ustawNazwisko(char * nzw){
- nazwisko = new string(nzw);
- }
- string zwrocNazwisko(){
- return *nazwisko;
- }
- };
- class Student : public Osoba{
- public:
- int nr_albumu;
- Student()
- : Osoba()
- {
- nr_albumu = -1;
- }
- Student(int r, char * nzw, int alb)
- : Osoba(r, nzw)
- {
- nr_albumu = alb;
- }
- };
- int main(){
- Osoba * pan = new Osoba(2000, "Adam");
- Student * studenciak = new Student(1998, "Marcin", 320084);
- pan->ustawRok(1997);
- cout << pan->zwrocNazwisko() << ", " << pan->zwrocRok() << endl;
- studenciak->ustawNazwisko("Mariusz");
- cout << studenciak->zwrocNazwisko() << ", " << studenciak->zwrocRok();
- return EXIT_SUCCESS;
- }
Add Comment
Please, Sign In to add comment