Cpp_notes_summary_7

Cpp_notes_summary_7 - Chapter 6 Advanced/Misc Topics 6.1...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Chapter 6 Advanced/Misc Topics 6.1 overload function overload void f f f ( int y , int x) { cout << ”x=” << x << ” , y=” << y << endl ; } void f f f ( int y) { int x=10; cout << ”x=” << x << ” , y=” << y << endl ; } void f f f ( double y) { double x=10.1; cout << ”x=” << x << ” , y=” << y << endl ; } f f f ( 3 ) ; //x=10, y=3 f f f (1000 ,5); //x=5, y=1000 f f f ( 1 0 0 0 . 0 ) ; x=10.1 , y=1000 6.2 optional arguments optional void f f f ( int x=10); // in header f i l e void f f f ( int x / =10 / ) { cout << ”x=” << x << endl ; } f f f (1000); // outputs 1000 f f f ( ) ; // outputs 10 If you do something like 52
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
MAT 5939-04 Pierre Garreau optional void f f f ( int y , int x=10, int z =12); // in header void f f f ( int y , int x / =10 / , int z / =12 / ) ; // in header { cout << ”x=” << x << ” , y=” << y << ” , z=” << z << endl ; } f f f ( 3 ) ; f f f (1000 ,5); outputs x=10, y=3, z=12 x=5, y=1000, z=12 x=5, y=1000, z=9 So the arguments are passed left to right. 6.3
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/15/2012 for the course MAT 5939 taught by Professor Garreau during the Fall '11 term at FSU.

Page1 / 4

Cpp_notes_summary_7 - Chapter 6 Advanced/Misc Topics 6.1...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online