Advanced C++ test === 你覺得你對 C++ 的認識有多少? 要來挑戰看看嗎? 以下題目皆為 ==Close book==,誠實面對自己,在 facebook 留言區,寫下你的答案吧! ![](https://i.imgur.com/21kV6Fb.png) ## 第一題 ![](https://i.imgur.com/fhKZ8fY.png) ## 第二題 ![](https://i.imgur.com/CJqixhs.png) ## 第三題 ![](https://i.imgur.com/NWt8deL.png) ## 第四題 :::danger 請回答 **Why**? ::: ![](https://i.imgur.com/YyFCNJQ.png) ## 第五題 :::danger 請回答 **Why**? ::: ![](https://i.imgur.com/OWmOuD2.png) ## 第六題 這題請給出你的數學證明: ![](https://i.imgur.com/pE8xWJe.png) ## 第七題 ![](https://i.imgur.com/tl7V5hG.png) ## 第八題 <!-- 這題不方便截圖,因此重製題目 --> 請修改 class `Complex` 讓 main function 可以正常編譯,並符合預期。 ```cpp= #include <cmath> class Complex { public: Complex(const double re = 0, const double im = 0) : real{re}, imag{im} {} ~Complex() = default; Complex (const Complex &) = default; Complex (Complex &&) = default; Complex &operator=(const Complex &) = default; Complex &operator=(Complex &&) = default; friend Complex Polar(const double leng, const double arg){ return Complex(leng * ::cos(arg), leng * ::sin(arg)); } friend Complex operator*(const Complex &x, const Complex &y) { return Complex(x.real * y.real - x.imag * y.imag, x.real * y.imag + x.imag * y.real); } friend Complex operator*=(Complex &x, const Complex &y) { return (x = x * y); } private: double real; double imag; }; int main(void){ Complex a(77, 66.3); a *= Polar(5.1, 5.1); return 0; } ``` ## 第九題 ![](https://i.imgur.com/f4MMbqg.png) ## 第十題 ![](https://i.imgur.com/e2sOG95.png)