Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Czujnik {
- public:
- void wyswietl();
- void pomiar();
- Czujnik(string nazwa);
- protected:
- string nazwa;
- double wartosc;
- };
- class CzujnikX : public Czujnik
- {
- public:
- void wyswietl()
- {
- cout << "Zmierzona wartosc: " << wartosc << endl;
- }
- };
- void main()
- {
- Czujnik *czujniki[10] = { NULL };
- czujniki[0] = new CzujnikTemperatury("silnik");
- czujniki[5] = new CzujnikTemperatury("tarcze");
- czujniki[7] = new CzujnikCisnienia("olej");
- for(int i=0; i<10; i++)
- if(czujniki[i] != NULL)
- {
- czujniki[i]->pomiar();
- czujniki[i]->wyswietl();
- }
- //...
- for(int i=0; i<10; i++)
- if(czujniki[i] != NULL)
- delete czujniki[i];
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement