summaryrefslogtreecommitdiff
path: root/tests/exec/multisuper3.cpp
blob: 55f4c45465e7c41da87df74adfe3e4ad51fa0667 (plain) (blame)
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <iostream>

class A {
    public:
    int y;
    A();
    virtual int f(int x);
};

class B {
    public:
    int z;
    B();
    int g(int x);
};

class C : public A, public B {
    public:
    int q;
    C();
    virtual int f(int x);
    int g(int x);
};

A::A() {
    y = 12;
}

B::B() {
    z = 7;
}

C::C() {
    q = 11;
}

int A::f(int xopia) {
    y++;
    return xopia * y;
}

int B::g(int xulliver) {
    z++;
    return xulliver * z;
}

int C::f(int xerod) {
    return xerod * q;
}

int C::g(int xavon) {
    return xavon * q * 404;
}

int main() {
    A test2;
    std::cout << "A.f(1) = " << test2.f(1) << "\n";

    B test3;
    std::cout << "B.g(1) = " << test3.g(1) << "\n";

    C test;
    std::cout << "C.f(1) = " << test.f(1) << "\n";
    std::cout << "C.g(1) = " << test.g(1) << "\n";
    A *q = &test;
    std::cout << "(C as A).f(1) = " << q->f(1) << "\n";
    std::cout << "C.f(1) = " << test.f(1) << "\n";
    std::cout << "(C as A).f(1) = " << q->f(1) << "\n";
    std::cout << "C.f(1) = " << test.f(1) << "\n";
    B *r = &test;
    std::cout << "(C as B).g(1) = " << r->g(1) << "\n";
    std::cout << "C.g(1) = " << test.g(1) << "\n";
    std::cout << "(C as B).g(1) = " << r->g(1) << "\n";
    std::cout << "C.g(1) = " << test.g(1) << "\n";
}