## 面試時間:2024/11 ### 1. C中define/ ifndef/ endif有何作用? >1. #define: 用來定義macro,常用來定義常數或簡化程式碼的重複部分。 >2. #ifndef: 是 "if not defined" 的縮寫,用來檢查一個符號是否尚未被定義。如果未定義,則執行接下來的程式碼。 >3. #endif: 用來結束 #if 或 #ifndef 的條件編譯區塊。 ### 2. #inclde<filename.h> 和 #include"filename.h" 有何差別? ><filename.h>:用於包含系統或標準庫中的檔案。 "filename.h":用於包含當前目錄或自定義的檔案。 ### 3. 寫出對應的輸出 ``` int n = 10; printf("N1=%d\n", n++); printf("N2=%d\n", ++n); ``` >N1=10 N2=12 ``` float f = 1234.56; float *f1=&f; float **f2=&f1; printf("%f\n", **f2); ``` >1234.560000 ``` float s[2]; *(s+1)=111.1; *s=*(s+1); printf("%f\n", s[0]); ``` >111.100000 ``` typedef struct{ char *s1; char *s2; }SS; SS s, *ps; s.s1 = "1234"; ps=&s; ``` * (*ps).s1=? * *ps->s1=? * *s.s1=? * *(ps->s1+3)=? > (*ps).s1 = "1234" ps->s1 = "1234" s.s1 = "1234" *(ps->s1 + 3) = '4' ### 4. 以C寫function接收字串a和字串b,回傳c字串將a和b接起來 ``` #include <stdio.h> #include <string.h> void concatStrings(char *a, char *b, char *c) { strcpy(c, a); strcat(c, b); } ``` ### 5. C++中的copy constructor是什麼? 什麼情況會被呼叫? >* Copy constructor在以下情況下會被呼叫: >1. 當物件用其他同類型的物件初始化時。 >2. 當物件作為參數以值傳遞方式傳遞給函式時。 >3. 當物件作為返回值返回時。 ### 6. C++中的encapsulationm, polymorphism, inheritance, function overloading是什麼? >1. encapsulationm:隱藏物件內部細節,只暴露必要的interface。 >2. polymorphism:相同interface,不同implementaion,根據物件類型執行對應方法。 >3. inheritance:從現有類別派生新類別,重用並擴展功能。 >4. function overloading:同名函式接受不同的參數,根據參數類型選擇調用。 ### 7. 在unipolar mode下,使用12-bit DAC,referencr voltage 4V,預計的resolution為? 若希望DAC=3V,數位值須給多少? >* 解析度:每個數位值約為 0.000977 V。 >* DAC 輸出 3V 時的數位值:數位值應為 3068。 ### 8. 翻譯 A. introduction B. general-purpose C. state-of-the-art D. 迴圈 E. 參數 F. 架構 >A. introduction - 介紹 B. general-purpose - 通用的 C. state-of-the-art - 先進的、最先進的 D. 迴圈 - loop E. 參數 - parameter F. 架構 - architecture