1 //
2 // Week 2, Initialization of Member Variables
3 //
4
5 class Foo
6 {
7 public:
8 Foo () {data = 0; }
9 Foo (int value) { data = value; }
10
11 int getData () const { return data; }
12 void setData (int value) { data = value; }
13
14 private:
15 int data;
16 };
17
18 class TwoFoos
19 {
20 public:
21 TwoFoos (int firstInt, int secondInt)
22 {
23 first.setData
(firstInt);
24 second.setData
(secondInt);
25 }
26
27 private:
28 Foo first;
29 Foo second;
30 };
31
32 //
33 // Assume the following code...what happens in
34 // what order?
35 //
36
37 void function ()
38 {
39 TwoFoos x (5, 6);
40 }
41