{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Cpp_notes_summary_7

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

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

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

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

View Full Document
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 Program arguments argument commands #include < iostream > using namespace std ; int main ( int argc , char argv [ ] ) { cout << ”ARGument Cout=” << argc << endl ; for ( int i =0; i < argc ; i++) { cout << ”argv [ ” << i << ”]=” << argv [ i ] << endl ; } return 0; } ./ a . out gives ARGument Cout=1 argv [0]=./ a . out
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### 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
Ask a homework question - tutors are online