VC++ (defaultArgument.cpp):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | //Chapter 3 - Default Argument #include <iostream> using namespace std; double circumference( double , double = 3.14); int main( void ) { //scientific使用科學記號輸出 cout << scientific << circumference(1) << endl; cout << scientific << circumference(1, acos (-1.0)) << endl; system ( "pause" ); return 0; } double circumference( double d, double pi) { return d * pi; } |
說明:
基礎的函式預設引數範例。
沒有留言:
張貼留言