2014-10-08 18:27:36 +00:00
|
|
|
class myInt {
|
|
|
|
|
private: int theValue;
|
|
|
|
|
public: myInt() : theValue(0) {}
|
|
|
|
|
public: myInt(int _x) : theValue(_x) {}
|
|
|
|
|
int val() { return theValue; }
|
|
|
|
|
};
|
|
|
|
|
|
2016-08-31 21:46:21 +00:00
|
|
|
class myIntAndStuff {
|
|
|
|
|
private:
|
|
|
|
|
int theValue;
|
|
|
|
|
double theExtraFluff;
|
|
|
|
|
public:
|
|
|
|
|
myIntAndStuff() : theValue(0), theExtraFluff(1.25) {}
|
|
|
|
|
myIntAndStuff(int _x) : theValue(_x), theExtraFluff(1.25) {}
|
|
|
|
|
int val() { return theValue; }
|
|
|
|
|
};
|
|
|
|
|
|
2015-10-21 19:28:08 +00:00
|
|
|
class myArray {
|
|
|
|
|
public:
|
|
|
|
|
int array[16];
|
|
|
|
|
};
|
|
|
|
|
|
2014-10-22 20:14:09 +00:00
|
|
|
class hasAnInt {
|
|
|
|
|
public:
|
|
|
|
|
myInt theInt;
|
|
|
|
|
hasAnInt() : theInt(42) {}
|
|
|
|
|
};
|
|
|
|
|
|
2014-10-08 18:27:36 +00:00
|
|
|
myInt operator + (myInt x, myInt y) { return myInt(x.val() + y.val()); }
|
2016-08-31 21:46:21 +00:00
|
|
|
myInt operator + (myInt x, myIntAndStuff y) { return myInt(x.val() + y.val()); }
|
2014-10-08 18:27:36 +00:00
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
|
myInt x{3};
|
|
|
|
|
myInt y{4};
|
|
|
|
|
myInt z {x+y};
|
2016-08-31 21:46:21 +00:00
|
|
|
myIntAndStuff q {z.val()+1};
|
2014-10-22 20:14:09 +00:00
|
|
|
hasAnInt hi;
|
2015-10-21 19:28:08 +00:00
|
|
|
myArray ma;
|
|
|
|
|
|
2014-10-08 18:27:36 +00:00
|
|
|
return z.val(); // break here
|
|
|
|
|
}
|