Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame^] | 1 | //===-- main.cpp ------------------------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | class A |
| 11 | { |
| 12 | public: |
| 13 | A(int i=0): |
| 14 | m_a_int(i), |
| 15 | m_aa_int(i+1) |
| 16 | { |
| 17 | } |
| 18 | |
| 19 | //virtual |
| 20 | ~A() |
| 21 | { |
| 22 | } |
| 23 | |
| 24 | int |
| 25 | GetInteger() const |
| 26 | { |
| 27 | return m_a_int; |
| 28 | } |
| 29 | void |
| 30 | SetInteger(int i) |
| 31 | { |
| 32 | m_a_int = i; |
| 33 | } |
| 34 | |
| 35 | protected: |
| 36 | int m_a_int; |
| 37 | int m_aa_int; |
| 38 | }; |
| 39 | |
| 40 | class B : public A |
| 41 | { |
| 42 | public: |
| 43 | B(int ai, int bi) : |
| 44 | A(ai), |
| 45 | m_b_int(bi) |
| 46 | { |
| 47 | } |
| 48 | |
| 49 | //virtual |
| 50 | ~B() |
| 51 | { |
| 52 | } |
| 53 | |
| 54 | int |
| 55 | GetIntegerB() const |
| 56 | { |
| 57 | return m_b_int; |
| 58 | } |
| 59 | void |
| 60 | SetIntegerB(int i) |
| 61 | { |
| 62 | m_b_int = i; |
| 63 | } |
| 64 | |
| 65 | protected: |
| 66 | int m_b_int; |
| 67 | }; |
| 68 | |
| 69 | |
| 70 | class C : public B |
| 71 | { |
| 72 | public: |
| 73 | C(int ai, int bi, int ci) : |
| 74 | B(ai, bi), |
| 75 | m_c_int(ci) |
| 76 | { |
| 77 | } |
| 78 | |
| 79 | //virtual |
| 80 | ~C() |
| 81 | { |
| 82 | } |
| 83 | |
| 84 | int |
| 85 | GetIntegerC() const |
| 86 | { |
| 87 | return m_c_int; |
| 88 | } |
| 89 | void |
| 90 | SetIntegerC(int i) |
| 91 | { |
| 92 | m_c_int = i; |
| 93 | } |
| 94 | |
| 95 | protected: |
| 96 | int m_c_int; |
| 97 | }; |
| 98 | |
| 99 | int |
| 100 | main (int argc, char const *argv[]) |
| 101 | { |
| 102 | A a(12); |
| 103 | B b(22,33); |
| 104 | C c(44,55,66); |
| 105 | return b.GetIntegerB() - a.GetInteger() + c.GetInteger(); |
| 106 | } |