freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內容

[理學]cppt第十三章-在線瀏覽

2024-12-03 20:22本頁面
  

【正文】 couts1 is not NULL!endl。 else couts2 is not NULL!endl。 } s1 is NULL! s2 is not NULL! 22 NUDT, Computer School, 602, 例 3:定義字符串類 String, 并以友元函數(shù)的方式重載運算符 ! 以判斷對象中的字符串是否為空串 (1/3) //文件 if !defined __STRING__H__ define __STRING__H__ include class String {//定義運算符重載友元函數(shù)原型 friend bool operator !(String amp。 public: String(char *m=)。 private: char *str。 endif 23 NUDT, Computer School, 602, 例 2:定義字符串類 String, 并以友元函數(shù)的方式重載運算符 ! 以判斷對象中的字符串是否為空串 (2/3) //文件 include include String::String(char *m) { str = new char[strlen(m)+1]。 } String::~String() { delete [] str。s)//實現(xiàn)友元函數(shù) { if (strlen() == 0) return true。 } 24 NUDT, Computer School, 602, 例 2:定義字符串類 String, 并以友元函數(shù)的方式重載運算符 ! 以判斷對象中的字符串是否為空串 (3/3) //文件 include include main() { String s1, s2(some string)。 else couts1 is not NULL!endl。 else couts2 is not NULL!endl。 } s1 is NULL! s2 is not NULL! 25 NUDT, Computer School, 602, 單目運算符重載 (2/3) ? 特殊的單目運算符 ++、 : 以 ++為例 ,設 b為類 C的對象 ? 前自增,如: ++b ? 重載函數(shù)可為 C的成員函數(shù),原型為 返回值類型 operator++()。)。 b++轉換為函數(shù)調用 ++(0) ? 重載函數(shù)也可為 C的友元函數(shù),原型為 返回值類型 operator++(C amp。 b++轉換為函數(shù)調用 operator++(b, 0) 27 NUDT, Computer School, 602, 重載流插入和流提取運算符 ? 語句 cout string。 ? cout是類 ostream的一個對象(定義于頭文件 ) ? 如何實現(xiàn): String s(string)。 例 4:重載流插入運算符 和流提取運算符 ,實現(xiàn)用cout和 cin直接輸出和輸入類 String的對象 (1/4) //文件 if !defined __STRING__H__ define __STRING__H__ include class String { friend ostream amp。output, String amp。 friend istream amp。input, String amp。 public: String(char *m= )。 private: char *str。 endif 例 4:重載流插入運算符 和流提取運算符 ,實現(xiàn)用cout和 cin直接輸出和輸入類 String的對象 (2/4) //文件 include include String::String(char *m) { str = new char[strlen(m)+1]。 } String::~String() { delete [] str。 operator(ostream amp。s) { output 。 } istream amp。input, String amp。 input temp。 = new char[strlen(temp)+1]。 return input。 cout Please input two strings: endl。 cout Output is: endl。 return 0。 operator(ostream amp。s)。 operator(istream amp。s)。 ~String()。 operator+=(String amp。 private: char *str。 endif 例 5: 重載運算符 +=使 x+=y實現(xiàn)將對象 y中的字符串連接到對象 x的字符串后面,連接后的 x作為運算結果 (2/5) //文件 , 類 String的實現(xiàn) include include String::String(char *m) { str = new char[strlen(m)+1]。 } String::~String() { delete [] str。 operator(ostream amp。s) { output。 } 例 5: 重載運算符 +=使 x+=y實現(xiàn)將對象 y中的字符串連接到對象 x的字符串后面,連接后的 x作為運算結果 (3/5) //續(xù) 文件 //定義運算符 的 重載函數(shù) istream amp。input, String amp。 cin temp。 = new char[strlen(temp)+1]。 return input。String::operator+=(String amp。 strcpy(temp, str)。 delete []str。 return *this。 cins1s2。 s1+=s2。 return
點擊復制文檔內容
教學課件相關推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1