xref: /llvm-project/lldb/test/API/lang/cpp/class_types/main.cpp (revision fdea9a4ec9b0d9585b8fe8a612686d9f44f40ddc)
1 class Conversion
2 {
3 public:
Conversion(int i)4     Conversion (int i) :
5       m_i (i)
6       {}
7 
operator bool()8     operator bool()
9     {
10         return m_i != 0;
11     }
12 
13 private:
14     int m_i;
15 };
16 
17 class A
18 {
19 public:
A(int i=0)20     A(int i=0):
21         m_a_int(i),
22         m_aa_int(i+1)
23     {
24     }
25 
26     //virtual
~A()27     ~A()
28     {
29     }
30 
31     int
GetInteger() const32     GetInteger() const
33     {
34         return m_a_int;
35     }
36     void
SetInteger(int i)37     SetInteger(int i)
38     {
39         m_a_int = i;
40     }
41 
42 protected:
43     int m_a_int;
44     int m_aa_int;
45 };
46 
47 class B : public A
48 {
49 public:
B(int ai,int bi)50     B(int ai, int bi) :
51         A(ai),
52         m_b_int(bi)
53     {
54     }
55 
56     //virtual
~B()57     ~B()
58     {
59     }
60 
61     int
GetIntegerB() const62     GetIntegerB() const
63     {
64         return m_b_int;
65     }
66     void
SetIntegerB(int i)67     SetIntegerB(int i)
68     {
69         m_b_int = i;
70     }
71 
72 protected:
73     int m_b_int;
74 };
75 
76 #include <cstdio>
77 class C : public B
78 {
79 public:
C(int ai,int bi,int ci)80     C(int ai, int bi, int ci) :
81         B(ai, bi),
82         m_c_int(ci)
83     {
84       std::printf("Within C::ctor() m_c_int=%d\n", m_c_int); // Set break point at this line.
85     }
86 
87     //virtual
~C()88     ~C()
89     {
90     }
91 
92     int
GetIntegerC() const93     GetIntegerC() const
94     {
95         return m_c_int;
96     }
97     void
SetIntegerC(int i)98     SetIntegerC(int i)
99     {
100         m_c_int = i;
101     }
102 
103 protected:
104     int m_c_int;
105 };
106 
107 int
main(int argc,char const * argv[])108 main (int argc, char const *argv[])
109 {
110     A a(12);
111     B b(22,33);
112     C c(44,55,66);
113     Conversion conv(1);
114     if (conv)
115         return b.GetIntegerB() - a.GetInteger() + c.GetInteger();
116     return 0;
117 }
118