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

正文內容

程序設計實習第二十一講習題課(編輯修改稿)

2025-08-28 12:42 本頁面
 

【文章內容簡介】 = new char[strlen(p) + strlen()+1]。 strcpy(q, p)。 strcat(q, )。 MyString temp(q)。 delete []q。 return temp。 } 北京大學 《 程序設計實習 》 課程 Mystring類 (3) MyString operator+(const char *s) // +號重載,這里表示 //MyString類型 +字符串的情形 { char *q。 q = new char[strlen(p) + strlen(s) + 1]。 strcpy(q, p)。 strcat(q, s)。 MyString temp(q)。 delete []q。 return temp。 } MyStringamp。 operator=(const MyString amp。s) // 賦值號重載 { if(p!=NULL) { delete[]p。 } p = new char[strlen()+1]。 strcpy(p, )。 return *this。 }0 北京大學 《 程序設計實習 》 課程 Mystring類 (4) char amp。operator[](int n) // []號重載 { return p[n]。 } MyStringamp。 operator+=(char *s) // +=號重載 { char *q。 q = new char[strlen(p)+1]。 strcpy(q, p)。 if(p != NULL) { delete []p。 } p = new char[strlen(p) + strlen(s) + 1]。 strcpy(p,q)。 strcat(p,s)。 delete []q。 return *this。 } 北京大學 《 程序設計實習 》 課程 Mystring類 (5) MyString operator()(int i, int n) { // ()重載 char *q。 q = new char[n+1]。 strncpy(q, p+i, n)。 q[n] = 39。\039。 MyString temp(q)。 delete []q。 return temp。 } }。 ostream amp。operator (ostream amp。o, const MyString amp。s) // 號重載 { o 。 return o。 } MyString operator+(char *s, const MyString amp。t) // +號重載,這里是字符串 +MyString的情形 { char q[100]。 strcpy(q, s)。 strcat(q, )。 return MyString(q)。 } 北京大學 《 程序設計實習 》 課程 Mystring類 (6) int operator(const MyString amp。s1, const MyString amp。s2) // ,==, 號的重載 { if(strcmp(,) 0) { return 1。 } else { return 0。 } } int operator==(const MyString amp。s1, const MyString amp。s2) { if(!strcmp(, )) { return 1。 } else { return 0。 } } int operator(const MyString amp。s1, const MyString amp。s2) { if(strcmp(, ) 0) { return 1。 } else { return 0。 } } 北京大學 《 程序設計實習 》 課程 Mystring類 (7) int CompareString(const void * e1, const void * e2) // 字符串比較函數(shù) { MyString * s1 = (MyString * ) e1。 MyString * s2 = (MyString * ) e2。 if(*s1 *s2 ) return 0。 else return 1。 } 北京大學 《 程序設計實習 》 課程 Mystring類 (8) 從 string類派生的寫法 class MyString : public string{ public: MyString():string() {}。 MyString( const char * s):string(s){}。 MyString( const string amp。 s ): string(s){}。 MyString operator() ( int s, int l) { return thissubstr(s,l)。 }。 }。 北京大學 《 程序設計實習 》 課程 繼承和多態(tài) (2) ? 寫出下面程序的運行結果 class B { private: int nBVal。 public: void Print() { cout nBVal= nBVal endl。 } void Fun() {cout B::Fun endl。 } B ( int n ) { nBVal = n。} }。 class D:public B { private : int nDVal。 public: void Print() { B::Print()。 cout nDVal=nDVal endl。 } D( int n) : B(3*n) {nDVal = n。} void Fun() { cout D::Fun endl。 } }。 北京大學 《 程序設計實習 》 課程 繼承和多態(tài) (2) main() { B * pb。 D * pd。 D d(4)。 ()。 pb = new B(2)。 pd = new D(8)。 pb Fun()。 pdFun()。 pbPrint ()。 pdPrint ()。 pb = amp。 d。 pbFun()。 pbPrint()。 } D::Fun B::Fun D::Fun nBVal=2 nBVal=24 nDVal=8 B::Fun nBVal=12 北京大學 《 程序設計實習 》 課程 繼承和多態(tài) (3) ?程序輸出結果如下,請?zhí)羁? A::Fun A::Do A::Fun C::Do class A { private: int nVal。 public: void Fun() { cout A::Fun endl。 }。 virtual void Do() { cout A::Do endl。 } }。 class B:public A { public: virtual void Do() { cout B::Do endl。} }。 class C:public B { public: void Do( ) { cout C::Doendl。 } void Fun() { cout C::Fun endl。 } }。 北京大學 《 程序設計實習 》 課程 繼承和多態(tài) (3) void Call(____________) { pFun()。 pDo()。 } main() { Call( new A())。 Call( new C())。 } A * p void Call(____________) { ()。 ()。 } main() { Call(A())。 Call(C())。 } A amp。 p 北京大學 《 程序設計實習 》 課程 模板 (1) ? *設計 CLinkList類模板中 AppendNode 和PrintList成員函數(shù),得到如下結果 0,1,2,3, 0,1,2,3,9,10,11, 注意: 1)不得調用任何庫函數(shù),庫模板,不得使用 static關鍵字,不得使用除 NULL 以外的任何常量 2)不得為 Node和 CLinkList模板添加任何成員 3)不得添加任何全局變量,不得添加其他函數(shù) 北京大學 《 程序設計實習 》 課程 模板 (1) template class D class Node { public: D data。 Node * next。 }。 templateclass D class CLinkList { private: NodeD * pHead。 public: CLinkList()。 void AppendNode( D data)。 void PrintList()。 }。 templateclass D CLinkList
點擊復制文檔內容
研究報告相關推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號-1