【正文】
類型為public(2)c++類可以有繼承,虛函數(shù),多態(tài),而C中struct不可以。mymemcpy( str+1, str+0, 9 )。 pdestpsrc+cout ) 能考慮到這種情況就行了{(lán)for( size_t i=count1。// 刪除array數(shù)組中所有的2for( IntArray::iterator itor=()。 i=0。)b endl。cout (int)a endl。 operator=( const Emptyamp。}}。8. 以下代碼能夠編譯通過嗎,為什么?[C++易]unsigned int const size1 = 2。cout endl。939。1)。45. 以下代碼有什么問題?[C難]void char2Hex( char c ) // 將字符以16進(jìn)制表示{char ch = c/0x10 + 39。a39。 isizeof(str)/sizeof(str[0])。str5和str6并非數(shù)組而是字符指針,并不分配存儲(chǔ)區(qū),其后的“abc”以常量形式存于靜態(tài)數(shù)據(jù)區(qū),而它們自己僅是指向該區(qū)首地址的指針,相等。 const char str4[] = abc。宏定義時(shí),字符串可以是任何類型的數(shù)據(jù)。 棧區(qū)(stack)— 由編譯器自動(dòng)分配釋放 ,存放函數(shù)的參數(shù)值,局部變量的值等。}if(N=)=NewNode。 !=NULL) || (Ntemp. value amp。 // Again, 數(shù)字任意給出}void append(int N){TNode* NewNode=(TNode *)malloc(sizeof(TNode))。void append(int N)。 elseif(n == 1 || n ==2)return 1。}} 遞歸#i nclude iostreamusing namespace std。int n2 = 1。可以用遞歸,也可以用其他方法,但要說明你選擇的理由。for(int i = 1。int main(){int array[]={45,56,76,234,1,34,23,2,3}。 j ni+1。Sony筆試題25.完成下列程序**.*.*..*..*..*...*...*...*...*....*....*....*....*....*.....*.....*.....*.....*.....*.....*......*......*......*......*......*......*......*.......*.......*.......*.......*.......*.......*.......*.......#i ncludeiostreamusing namespace std。只是在類對(duì)象生命期結(jié)束時(shí)由系統(tǒng)自動(dòng)調(diào)用。while(ps){ penext = psnext。 B const* int a = amp。(4)系統(tǒng)利用WNDCLASS結(jié)構(gòu)體的lpfnWndProc成員保存的窗口過程函數(shù)的指針調(diào)用窗口過程,對(duì)消息進(jìn)行處理(即“系統(tǒng)給應(yīng)用程序發(fā)送了消息”)。 cinc。 i。 if (len j + 1) return false。\t39。tpnext=ptrnext。kp) {ptr=ptrnext。ptrnext=ptrnextnext。listnodetype *ptr,*t。二、在棧上創(chuàng)建。用戶只需要按照頭文件中的接口聲明來(lái)調(diào)用庫(kù)功能,而不必關(guān)心接口怎么實(shí)現(xiàn)的。如果某個(gè)接口被實(shí)現(xiàn)或被使用時(shí),其方式與頭文件中的聲明不一致,編譯器就會(huì)指出錯(cuò)誤,這一簡(jiǎn)單的規(guī)則,能大大減輕程序員調(diào)試、改錯(cuò)的負(fù)擔(dān)。三、從堆上分配,亦稱動(dòng)態(tài)內(nèi)存分配。amp。}在節(jié)點(diǎn)P后插入一個(gè)節(jié)點(diǎn):templateclass type bool listtype::insert(type t,int p){listnodetype *ptr。amp。return true。\039。) buf[j] = buf[i]。 coutBefore chage:endl。(2)應(yīng)用程序在消息循環(huán)中調(diào)用GetMessage函數(shù)從消息隊(duì)列中取出一條一條的消息。例外情況:如, 在windows編程中,可以編寫一個(gè)動(dòng)態(tài)連接庫(kù)(dll)模塊,這是其他windows程序可以使用的代碼。b。ps = penext。全局變量由編譯器建立且存放在內(nèi)存的全局?jǐn)?shù)據(jù)區(qū),局部變量存放在棧區(qū).22 一些寄存器的題目,主要是尋址和內(nèi)存管理等一些知識(shí)。int j。 k ni+1。 i = 8。 k 9 i。main(){int Ph = Pheponatch(10)。 i = n。cinn。#i nclude #i nclude typedef struct{TNode* left。append(32)。return。amp。 }}29. A class B network on the internet has a subnet mask of , what is the maximum number of hosts per subnet .a. 240 b. 255 c. 4094 d. 6553430. What is the difference: between o(log n) and o(log n^2), where both logarithems have base 2 .a. o(log n^2) is bigger b. o(log n) is biggerc. no difference31. For a class what would happen if we call a class’s constructor from with the same class’s constructor .a. pilation error b. linking errorc. stack overflow d. none of the above32. “new” in c++ is a: .a. library function like malloc in cb. key word c. operatord. none of the above33. Which of the following information is not contained in an inode .a. file owner b. file sizec. file name d. disk address34. What’s the number of parisons in the worst case to merge two sorted lists containing n elements each .a. 2n +1 35. Time plexity of n algorithm T(n), where n is the input size ,is T(n)=T(n1)+1/n if n1 otherwise 1 the order of this algorithm is .a. log (n) b. n c. n^2 d. n^n36. The number of 1’s in the binary representation of 3*4096+ 15*256+5*16+3 are .a. 8 b. 9 c. 10 d. 1237.設(shè)計(jì)函數(shù) int atoi(char *s)。注意它與數(shù)據(jù)結(jié)構(gòu)中的堆是兩回事,分配方式倒是類似于鏈表.41.論述含參數(shù)的宏與函數(shù)的優(yōu)缺點(diǎn)。,只占編譯時(shí)間;而函數(shù)調(diào)用則占運(yùn)行時(shí)間(分配單元、保留現(xiàn)場(chǎng)、值傳遞、返回)。cout boolalpha ( str1==str2 ) endl。 )。=str[i] amp。 )。939。 if( cl 39。 39。()。cin temp。49. C++中的空類,默認(rèn)產(chǎn)生哪些類成員函數(shù)?[C++易]答:class Empty{public:Empty()。()。cout boolalpha ( (int)a == (intamp。 // 輸出151. 以下反向遍歷array數(shù)組的方法有什么錯(cuò)誤?[STL易]vector array。IntArray array。}53. 寫一個(gè)函數(shù),完成內(nèi)存之間的拷貝。}else{for( size_t i=0。return 0。如果基類的函數(shù)用virtual修飾,成為虛函數(shù),則其派生類相應(yīng)的重載函數(shù)仍能繼承該虛函數(shù)的性質(zhì),虛函數(shù)進(jìn)行動(dòng)態(tài)聯(lián)編,也即具有多態(tài)性,也就是派生類可以改變基類同名函數(shù)的行為,在面向?qū)ο笫澜缰?,多態(tài)是最強(qiáng)大的機(jī)制,虛函數(shù)就是這一機(jī)制的c++實(shí)現(xiàn)方式。Test b()。private:CString strName。B,結(jié)構(gòu)中不允許定義成員函數(shù),當(dāng)是類中可以定義成員函數(shù)。()。()。編譯器會(huì)從庫(kù)中提取相應(yīng)的代碼。在執(zhí)行函數(shù)時(shí),函數(shù)內(nèi)局部變量的存儲(chǔ)單元都可以在棧上創(chuàng)建,函數(shù)執(zhí)行結(jié)束時(shí)這些存儲(chǔ)單元自動(dòng)被釋放。ptr=first。length。k++。ptrnext=tp。int n = 10。 在C++ 程序中調(diào)用被 C編譯器編譯后的函數(shù),為什么要加 extern “C”聲明? 答:C++語(yǔ)言支持函數(shù)重載,C 語(yǔ)言不支持函數(shù)重載。elseDoOtherthing()。}void Test(void) {char *str = NULL。printf(str)。strcpy(str, “hello”)。for(int i=0。other)。//答案一并給出一、請(qǐng)?zhí)顚態(tài)OOL , float, 指針變量 與“零值”比較的 if 語(yǔ)句。如下是錯(cuò)誤的寫法,不得分。#i nclude 和 #i nclude “” 有什么區(qū)別?(5分)答:對(duì)于#i nclude ,編譯器從標(biāo)準(zhǔn)庫(kù)路徑開始搜索 對(duì)于#i nclude “” ,編譯器從用戶的工作路徑開始搜索 const 有什么用途?(請(qǐng)至少說明兩種)(5分)答:(1)可以定義 const 常量(2)const可以修飾函數(shù)的參數(shù)、返回值,甚至函數(shù)的定義體。 iN。 i++)DoOtherthing()。因?yàn)镚etMemory并不能傳遞動(dòng)態(tài)內(nèi)存,Test函數(shù)中的 str一直都是 NULL。}請(qǐng)問運(yùn)行Test函數(shù)會(huì)有什么樣的結(jié)果?答:可能是亂碼。}請(qǐng)問運(yùn)行Test函數(shù)會(huì)有什么樣的結(jié)果?答:(1)能夠輸出hello(2)內(nèi)存泄漏void Test(void){char *str = (char *) malloc(100)。28 下列程序運(yùn)行時(shí)會(huì)崩潰,請(qǐng)找出錯(cuò)誤并改正,并且說明原因。TNode* root=NULL。append(17)。}else{TNode* temp。 templeft!=NULL)temp=templeft。4,C 和 C++ 中都有結(jié)構(gòu)的概念,但是在 C 語(yǔ)言中結(jié)構(gòu)只有成員變量,而沒成員方法,而在 C++ 中結(jié)構(gòu)中,它可以有自己的成員變量和成員函數(shù)。 10,調(diào)試功能強(qiáng)大,并且方法多樣。4 引用在初始化后不可以改變引用關(guān)系,而指針可以隨時(shí)指向其他對(duì)象(非const指針)。一個(gè)函數(shù)能否即是虛函數(shù)又是內(nèi)聯(lián)函數(shù)?8.以下關(guān)鍵字的含義與用法:extern,extern “C”,static,explicit,register,undef,ifndef9.什么是函數(shù)重載與覆蓋?為什么C不支持函數(shù)重載?為什么C++能支持函數(shù)重載?10.VC中,編譯工具條內(nèi)的Debug與Release選項(xiàng)是什么含義?11.編寫my_memcpy函數(shù),實(shí)現(xiàn)與庫(kù)函數(shù)memcpy類似的功能,不能使用任何庫(kù)函數(shù);void* mymemcpy(void* pvTo, const char* pvFrom, size_t size){assert((dest != NULL) amp。amp?! ?.寫一個(gè)函數(shù),將其中的\t都轉(zhuǎn)換成4個(gè)空格。 C const int* const a = amp。 return。 struct mybitfields { unsigned short a : 4。test)。 int c。 printf(a=%d\n,a)。virtual可加可不加。 void main() { char a[50]。istrlen(a)/2。 coutstr?,F(xiàn)在常用段頁(yè)式管理塊式管理:把主存分為一大塊、一大塊的,當(dāng)所需的程序片斷不在主存時(shí)就分配一塊主存空間,把程序片段load入主存,就算所需的程序片段只有幾個(gè)字節(jié)也只能把這一塊分配給它。各種內(nèi)存管理都有它自己的方法來(lái)計(jì)算出程序片斷在主存中的物理地址,其實(shí)都很相似。 } 這道題目的結(jié)果是什么啊? define 只是定義而已,在編擇時(shí)只是簡(jiǎn)單代換X*X而已,并不經(jīng)過算術(shù)法則的 a /= (k+m)*(k+m)/(k+m)*(k+m)。 char c2=39