# 實習課第七次作業 ###### tags: `NTOU CSE C++ Programming` > 教學文件和作業說明文件: https://hackmd.io/@kogiokka/ntou-cse-cpp-nav > 範例程式和範例專案:[Google Drive]( https://drive.google.com/drive/folders/100YvcqccLgY_27mJnubRSuPALrMAghJQ?usp=sharing) ## 實習目標 練習比較 function 不同的撰寫方式. 1. function overloading 1. default arguments 1. function template 1. `#define` 1. reference ## 題目 寫 function product 計算二或三個數字(int 或 float)乘積。 1. 使用巨集(`#define`) 1. 使用 function overloading 以及 default arguments 1. 使用 function template 以及 function overloading 1. 使用 function template 以及 default arguments 參考範例檔案:`Functions.cpp` ### 需求 計算結果存放在第一個參數,即使用參照(reference)語法傳入函式中。 ### 測試案例 ```cpp int result; product(result, 1, 2); cout << result << endl; product(result, 1, 2, 3); cout << result << endl; float result2; product(result2, 1.1f, 2.2f); cout << result2 << endl; product(result2, 1.1f, 2.2f, 3.3f); cout << result2 << endl; ``` ## 作業上傳規定 格式:`<學號>-<姓名>.zip`,例如:`11057022-江柏毅.zip` 如果你是用 Visual Studio,請刪除下列資料夾再上傳:**`.vs`**、`out`、`Debug`、`x64`。 使用其他 IDE 的同學也請刪掉建置資料夾再上傳,例如:`build`、`out`。
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up