Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef KOLOKWIUM_H
- #define KOLOKWIUM_H
- #include <iostream>
- #include <cstdlib>
- #include <cstring>
- using namespace std;
- class Kolokwium
- {
- static int liczbaPuntkow;
- char* student;
- float ocena;
- public:
- Kolokwium(const char* s, float o);
- ~Kolokwium();
- void wypisz() const;
- friend istream& operator>>(istream& , Kolokwium&);
- void zmienNazweStudenta(const char*);
- };
- #endif // KOLOKWIUM_H
- ///////////////////////////////
- #include "kolokwium.h"
- int Kolokwium::liczbaPuntkow = 21;
- Kolokwium::Kolokwium(const char* s, float o)
- {
- student = new char[strlen(s)+1];
- strcpy(student,s);
- ocena = o;
- liczbaPuntkow++;
- }
- Kolokwium::~Kolokwium()
- {
- --liczbaPuntkow;
- delete []student;
- }
- void Kolokwium::wypisz() const
- {
- cout <<"Student: " << student << endl
- << "Ocena: " << ocena << endl;
- }
- istream& operator>>(istream& is , Kolokwium& K)
- {
- cout <<"Podaj imie studenta: ";
- is >> K.student;
- cout <<"Podaj ocene: ";
- is>>K.ocena;
- return is;
- }
- void Kolokwium::zmienNazweStudenta(const char* nazwa)
- {
- this->student = new char[strlen(nazwa)+1];
- strcpy(student,nazwa);
- }
- void wypisz()
- {
- cout << student << ocena<<
- }
- ////////////////////////////////
- #include "kolokwium.h"
- using namespace std;
- int main()
- {
- // Kolokwium k1;
- Kolokwium k2("Sylwia",5);
- Kolokwium k3("Krzysiu",4);
- k2.wypisz();
- k3.wypisz();
- cin >> k2 ;
- k2.wypisz();
- cout << endl;
- k2.zmienNazweStudenta("Karol");
- k2.wypisz();
- return 0;
- }
- /////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement