42 lines · cpp
1class myInt {2 private: int theValue;3 public: myInt() : theValue(0) {}4 public: myInt(int _x) : theValue(_x) {}5 int val() { return theValue; }6};7 8class myIntAndStuff {9private:10 int theValue;11 double theExtraFluff;12public:13 myIntAndStuff() : theValue(0), theExtraFluff(1.25) {}14 myIntAndStuff(int _x) : theValue(_x), theExtraFluff(1.25) {}15 int val() { return theValue; }16};17 18class myArray {19public:20 int array[16];21};22 23class hasAnInt {24 public:25 myInt theInt;26 hasAnInt() : theInt(42) {} 27};28 29myInt operator + (myInt x, myInt y) { return myInt(x.val() + y.val()); }30myInt operator + (myInt x, myIntAndStuff y) { return myInt(x.val() + y.val()); }31 32int main() {33 myInt x{3};34 myInt y{4};35 myInt z {x+y};36 myIntAndStuff q {z.val()+1};37 hasAnInt hi;38 myArray ma;39 40 return z.val(); // break here41}42