呵呵,不知道對一些筆/面試是否有幫助 :)
1. 以下三條輸出語句分別輸出什麼?[c易]
char str1 = "abc";
char str2 = "abc";
const char str3 = "abc";
const char str4 = "abc";
const char* str5 = "abc";
const char* str6 = "abc";
cout << boolalpha << ( str1==str2 ) << endl; // 輸出什麼?
cout << boolalpha << ( str3==str4 ) << endl; // 輸出什麼?
cout << boolalpha << ( str5==str6 ) << endl; // 輸出什麼?
2. 非c++內建型別 a 和 b,在哪幾種情況下b能隱式轉化為a?[c++中等] 答:
a. class b : public a // b公有繼承自a,可以是間接繼承的
b. class b // b實現了隱式轉化為a的轉化
c. class a // a實現了non-explicit的引數為b(可以有其他帶預設值的引數)建構函式
d. a& operator= ( const a& ); // 賦值操作,雖不是正宗的隱式型別轉換,但也可以勉強算乙個
3. 以下**中的兩個sizeof用法有問題嗎?[c易]
void uppercase( char str ) // 將 str 中的小寫字母轉換成大寫字母
char str = "i love 中國";
for( size_t i=0; i> temp;
unsigned int const size2 = temp;
char str2[ size2 ];
8. 以下**中的輸出語句輸出0嗎,為什麼?[c++易]
struct cls
cls()
}; cls obj;
cout << obj.m_i << endl;
9. c++中的空類,預設產生哪些類成員函式?[c++易] 答:
class empty ;
10. 以下兩條輸出語句分別輸出什麼?[c++難]
float a = 1.0f;
cout << (int)a << endl;
cout << (int&)a << endl;
cout << boolalpha << ( (int)a == (int&)a ) << endl; // 輸出什麼?
float b = 0.0f;
cout << (int)b << endl;
cout << (int&)b << endl;
cout << boolalpha << ( (int)b == (int&)b ) << endl; // 輸出什麼?
11. 以下反向遍歷array陣列的方法有什麼錯誤?[stl易]
vector array;
array.push_back( 1 );
array.push_back( 2 );
array.push_back( 3 );
for( vector::size_type i=array.size()-1; i>=0; --i ) // 反向遍歷array陣列
12. 以下**有什麼問題?[stl易]
typedef vector intarray;
intarray array;
array.push_back( 1 );
array.push_back( 2 );
array.push_back( 2 );
array.push_back( 3 );
// 刪除array陣列中所有的2
for( intarray::iterator itor=array.begin(); itor!=array.end(); ++itor )
13. 寫乙個函式,完成記憶體之間的拷貝。[考慮問題是否全面] 答:
void* mymemcpy( void *dest, const void *src, size_t count )
else
return dest; }
int main( void )
C C 筆試題集錦
1.求下面函式的返回值 微軟 int func x int countx 0 while x countx x x x 1 return countx 假定x 9999。答案 8 思路 將x轉化為2進製,看含有的1的個數。2.什麼是 引用 申明和使用 引用 要注意哪些問題?答 引用就是某個目標變數的...
C C 技術筆試題
指標 include void getmemery char p,int num int main 答案 程式崩潰。實際上分配記憶體的只是形參p的乙個副本,函式呼叫結束後p又沒有返回給str,strcpy的str實際上是沒有分配記憶體。如果想不通過返回值的方式給str分配記憶體,程式如下。inclu...
C C 筆試題 一
1.include class shape shape int main int aaa std cin aaa 輸出的是ctorctordtor,因為b沒有呼叫delete析構 a與b有什麼區別了,就是乙個在棧上,乙個在堆上嗎?2.c語言是從那種語言發展而來的?答案很直接,從b語言發展而來的 3....