summaryrefslogtreecommitdiffstats
path: root/class_ref.cpp
blob: 179c967ffc0c782995e00893b2d4ba791026c6ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <iostream>
#include <cstdlib>

class Drink
{
    public:
    Drink(int cost)
    {
        this->cost = cost;
    }


    int get_cost(void);

    private:

    protected:
    int cost;
};

int Drink::get_cost(void)
{
    return cost;
}

class Juice : public Drink
{
    public:
    Juice(int shelf, int cost) : Drink(cost), shelf(shelf)
    {
        std::cout << "got called\n";
    }

    int get_shelf(void);

    private:
    int shelf;    

    protected:
};

int Juice::get_shelf(void)
{
    return shelf;
}

int main(int argc, char **argv)
{
    Juice *dubjuice = new Juice(1, 5);
    std::cout << dubjuice->get_cost() << std::endl;
    std::cout << dubjuice->get_shelf() << std::endl;

    Juice ref = *dubjuice;
    std::cout << ref.get_cost() << std::endl;
    std::cout << ref.get_shelf() << std::endl;

    return 0;
}