Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //============================================================================
- // Name : Kolos_2.cpp
- // Author :
- // Version :
- // Copyright : Your copyright notice
- // Description : Hello World in C++, Ansi-style
- //============================================================================
- #include <iostream>
- using namespace std;
- class Zad2 {
- int x, *tab;
- public:
- Zad2(int a = 5) :
- x(a) {
- tab = new int[a];
- }
- Zad2(char a) :
- Zad2() {
- cout << "delegacja" << endl;
- }
- void pobierz_wstaw() {
- int y, liczb;
- char znak;
- do {
- cout << "wybierz indeks" << endl;
- cin >> y;
- cout << "w - wstaw p - pobierz a - zakoncz" << endl;
- cin >> znak;
- if ((y < 0) || ((x - 1) < y)) {
- cout << "przekroczyles wielkosc tablicy" << endl;
- } else {
- switch (znak) {
- case ('w'):
- cout << "wybierz inta do wstawienia" << endl;
- cin >> liczb;
- tab[y] = liczb;
- cout << tab[y] << endl;
- break;
- case ('p'):
- cout << tab[y] << endl;
- break;
- default:
- break;
- }
- }
- } while (znak != 'a');
- }
- ~Zad2() {
- delete[] tab;
- }
- }
- ;
- class Zwierze {
- public:
- virtual void polowanie(int a)=0;
- virtual ~Zwierze() {
- }
- };
- class Lew: public Zwierze {
- int sila;
- public:
- virtual void polowanie(int a) {
- cout << "uderza lapa" << endl;
- }
- void uderzLapa() {
- polowanie(sila);
- }
- };
- class Lis: public Zwierze {
- int spryt;
- public:
- virtual void polowanie(int a) {
- cout << "drapie pazurem" << endl;
- }
- void Zadraplapa() {
- polowanie(spryt);
- }
- };
- class Wilk: public Zwierze {
- int szybkosc;
- public:
- virtual void polowanie(int a) {
- cout << "gryzie" << endl;
- }
- void ugryz() {
- polowanie(szybkosc);
- }
- };
- void zad1(int *a) {
- cout << "wartosc:";
- cout << *a << endl;
- cout << "adres:";
- cout << a << endl;
- cout << "adres wskaznika:";
- cout << &a << endl;
- *a += 5;
- }
- int main() {
- /*Lew *uderz = new Lew();
- uderz->uderzLapa();
- Wilk *gryz = new Wilk();
- gryz->ugryz();*/
- Zad2 *wsk = new Zad2();
- wsk->pobierz_wstaw();
- delete wsk;
- /*int a = 5;
- int *wsk = &a;
- cout << a << endl;
- cout << &a << endl;
- cout << &wsk << endl;
- zad1(wsk);
- cout << a << endl;
- return 0;*/
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement