統測
115年
[電機與電子群資電類] 專業科目(2)
第 47 題
在 C++ 語言中,想要定義類別名稱為 Student 的建構子(Constructor),下列何者正確?
- A Student(int wh){ ... }
- B int Student(int hw){ ... }
- C double Student(double weight, double height){ ... }
- D void Student(height, weight){ ... }
思路引導 VIP
回想一下物件導向中「建構子」的定義與特性:它與一般成員函數相比,在『函數名稱』以及『回傳型態(Return Type)』的宣告上有什麼特殊規定呢?
🤖
AI 詳解
AI 專屬家教
太棒了,你的觀念非常扎實!
建構子(Constructor)的定義規則
在 C++ 物件導向程式設計中,建構子具有兩大核心語法特徵:
▼ 還有更多解析內容