int main() { Circle luke (10.5); Circle wallace; Circle lindsay = 6.2; Circle owen(lindsay); Circle isaac = luke + lindsay; cout << "luke's area: " << luke.area() << "\n"; cout << "luke's circum: " << luke.circum() << "\n\n"; cout << "lindsay's area: " << lindsay.area() << "\n"; cout << "lindsay's circum: " << lindsay.circum() << "\n\n"; cout << "owen's area: " << owen.area() << "\n"; cout << "owen's circum: " << owen.circum() << "\n\n"; cout << "isaac's area: " << isaac.area() << "\n"; cout << "isaac's circum: " << isaac.circum() << "\n\n"; cout << "wallace's area: " << wallace.area() << "\n"; cout << "wallace's circum: " << wallace.circum() << "\n\n\n"; int a = 123; int b = 456; cout << "before swap: a = " << a << " and b = " << b << "\n"; swapInts(a, b); cout << "after swap: a = " << a << " and b = " << b << "\n"; return 0; }
int main () { Circle foo (10.0); // functional form Circle bar = 20.0; // assignment init. Circle baz {30.0}; // uniform init. Circle qux = {40.0}; // POD-like cout << "foo's circumference: " << setprecision(5) << foo.circum() << '\n'; return 0; }
int main(){ Circle foo(10);// functional form Circle bar = 10;// assignmemt init // Circle baz = {30};// in C++98 'baz' must be initialized by constructor, not by '{...}' // Circle qux {50};// C++98 'qux' must be initialized by constructor, not by '{...}' cout<<"foo's circum is "<<foo.circum()<<endl; cout<<"bar's circum is "<<bar.circum()<<endl; return 0; }