Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class klasa
- {
- private:
- int zm_int;
- char zm_char;
- long int zm_lint;
- public:
- double zm_double;
- string zm_string;
- void wys();
- klasa();
- bool metoda(int liczba);
- };
- klasa::klasa()
- :zm_int(10),
- zm_char('a'),
- zm_lint(12),
- zm_double(10.12),
- zm_string("BOOM!!")
- {}
- bool klasa::metoda(int liczba)
- {
- if ((zm_int > 0) && (zm_int < 100))
- { zm_int = liczba;
- return true;
- }
- else
- return false;
- }
- void klasa::wys()
- {
- cout<<"zm_int "<<zm_int<<endl;
- cout<<"zm_char "<<zm_char<<endl;
- cout<<"zm_lint "<<zm_lint<<endl;
- cout<<"zm_double "<<zm_double<<endl;
- cout<<"zm_string "<<zm_string<<endl;
- }
- int main()
- {
- klasa k;
- klasa *wsk_k = new klasa;
- cout<<"Statyczny obiekt"<<endl;
- k.wys();
- cout<<"Dynamiczny obiekt"<<endl;
- wsk_k->wys();
- cout<<"return z metoda "<<k.metoda(40)<<endl;
- delete(wsk_k);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement