C++課后習題答案 第八章多態性_第1頁
C++課后習題答案 第八章多態性_第2頁
C++課后習題答案 第八章多態性_第3頁
C++課后習題答案 第八章多態性_第4頁
C++課后習題答案 第八章多態性_第5頁
已閱讀5頁,還剩17頁未讀 繼續免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、第 八 章 多態性8-1 什么叫做多態性 ?在C+中是如何實現多態的?解:多態是指同樣的消息被不同類型的對象接收時導致完全不同的行為,是對類的特定成員函數的再抽象。C+支持的多態有多種類型,重載(包括函數重載和運算符重載)和虛函數是其中主要的方式。8-2 什么叫做抽象類?抽象類有何作用?抽象類的派生類是否一定要給出純虛函數的實現?解:帶有純虛函數的類是抽象類。抽象類的主要作用是通過它為一個類族建立一個公共的接口,使它們能夠更有效地發揮多態特性。抽象類聲明了一組派生類共同操作接口的通用語義,而接口的完整實現,即純虛函數的函數體,要由派生類自己給出。但抽象類的派生類并非一定要給出純虛函數的實現,如

2、果派生類沒有給出純虛函數的實現,這個派生類仍然是一個抽象類。8-3 聲明一個參數為整型,無返回值,名為fn1的虛函數。解:virtual void fn1( int );8-4 在C+中,能否聲明虛構造函數?為什么?能否聲明虛析構函數?有何用途?解:在C+中,不能聲明虛構造函數,多態是不同的對象對同一消息有不同的行為特性,虛函數作為運行過程中多態的基礎,主要是針對對象的,而構造函數是在對象產生之前運行的,因此虛構造函數是沒有意義的;可以聲明虛析構函數,析構函數的功能是在該類對象消亡之前進行一些必要的清理工作,如果一個類的析構函數是虛函數,那么,由它派生而來的所有子類的析構函數也是虛函數。析構函

3、數設置為虛函數之后,在使用指針引用時可以動態聯編,實現運行時的多態,保證使用基類的指針就能夠調用適當的析構函數針對不同的對象進行清理工作。8-5 實現重載函數Double(x),返回值為輸入參數的兩倍;參數分別為整型、長整型、浮點型、雙精度型,返回值類型與參數一樣。解:源程序:#include <iostream.h>int Double(int);long Double(long);float Double(float);double Double(double);int main()int myInt = 6500;long myLong = 65000;float myFlo

4、at = 6.5F;double myDouble = 6.5e20;int doubledInt;long doubledLong;float doubledFloat;double doubledDouble;cout << "myInt: " << myInt << "n"cout << "myLong: " << myLong << "n"cout << "myFloat: " << myFl

5、oat << "n"cout << "myDouble: " << myDouble << "n"doubledInt = Double(myInt);doubledLong = Double(myLong);doubledFloat = Double(myFloat);doubledDouble = Double(myDouble);cout << "doubledInt: " << doubledInt << "n&q

6、uot;cout << "doubledLong: " << doubledLong << "n"cout << "doubledFloat: " << doubledFloat << "n"cout << "doubledDouble: " << doubledDouble << "n"return 0;int Double(int original)cout <

7、;< "In Double(int)n"return 2 * original;long Double(long original)cout << "In Double(long)n"return 2 * original;float Double(float original)cout << "In Double(float)n"return 2 * original;double Double(double original)cout << "In Double(double)n

8、"return 2 * original;程序運行輸出:myInt: 6500myLong: 65000myFloat: 6.5myDouble: 6.5e+20In Double(int)In Double(long)In Double(float)In Double(double)DoubledInt: 13000DoubledLong: 130000DoubledFloat: 13DoubledDouble: 1.3e+218-6 定義一個Rectangle類,有長itsWidth、寬itsLength等屬性,重載其構造函數Rectangle()和Rectangle(int w

9、idth, int length)。解:源程序:#include <iostream.h>class Rectanglepublic:Rectangle();Rectangle(int width, int length);Rectangle() int GetWidth() const return itsWidth; int GetLength() const return itsLength; private:int itsWidth;int itsLength;Rectangle:Rectangle()itsWidth = 5;itsLength = 10;Rectangl

10、e:Rectangle (int width, int length)itsWidth = width;itsLength = length;int main()Rectangle Rect1;cout << "Rect1 width: " << Rect1.GetWidth() << endl;cout << "Rect1 length: " << Rect1.GetLength() << endl;int aWidth, aLength;cout << "E

11、nter a width: "cin >> aWidth;cout << "nEnter a length: "cin >> aLength;Rectangle Rect2(aWidth, aLength);cout << "nRect2 width: " << Rect2.GetWidth() << endl;cout << "Rect2 length: " << Rect2.GetLength() << endl;

12、return 0;程序運行輸出:Rect1 width: 5Rect1 length: 10Enter a width: 20Enter a length: 50Rect2 width: 20Rect2 length: 508-7 定義計數器Counter類,對其重載運算符 + 。解:源程序:typedef unsigned short USHORT;#include <iostream.h>class Counterpublic:Counter();Counter(USHORT initialValue);Counter()USHORT GetItsVal()const retu

13、rn itsVal; void SetItsVal(USHORT x) itsVal = x; Counter operator+ (const Counter &);private:USHORT itsVal;Counter:Counter(USHORT initialValue):itsVal(initialValue)Counter:Counter():itsVal(0)Counter Counter:operator+ (const Counter & rhs)return Counter(itsVal + rhs.GetItsVal();int main()Count

14、er varOne(2), varTwo(4), varThree;varThree = varOne + varTwo;cout << "varOne: " << varOne.GetItsVal()<< endl;cout << "varTwo: " << varTwo.GetItsVal() << endl;cout << "varThree: " << varThree.GetItsVal() << endl;retur

15、n 0;程序運行輸出:varOne: 2varTwo: 4varThree: 68-8 定義一個哺乳動物Mammal類,再由此派生出狗Dog類,二者都定義 Speak()成員函數,基類中定義為虛函數,定義一個Dog類的對象,調用Speak函數,觀察運行結果。解:源程序:#include <iostream.h>class Mammalpublic:Mammal():itsAge(1) cout << "Mammal constructor.n" Mammal() cout << "Mammal destructor.n"

16、; virtual void Speak() const cout << "Mammal speak!n" ;class Dog : public Mammalpublic:Dog() cout << "Dog Constructor.n" Dog() cout << "Dog destructor.n" void Speak()const cout << "Woof!n" ;int main()Mammal *pDog = new Dog;pDog->Spea

17、k();return 0;程序運行輸出:Mammal constructor.Dog constructor.Woof!Dog destructor.Mammal destructor.8-9 定義一個Shape抽象類,在此基礎上派生出Rectangle和Circle,二者都有GetArea()函數計算對象的面積,GetPerim()函數計算對象的周長。解:源程序:#include <iostream.h>class Shapepublic:Shape()Shape()virtual float GetArea() =0 ;virtual float GetPerim () =0

18、;class Circle : public Shapepublic:Circle(float radius):itsRadius(radius)Circle()float GetArea() return 3.14 * itsRadius * itsRadius; float GetPerim () return 6.28 * itsRadius; private:float itsRadius;class Rectangle : public Shapepublic:Rectangle(float len, float width): itsLength(len), itsWidth(wi

19、dth);Rectangle();virtual float GetArea() return itsLength * itsWidth; float GetPerim () return 2 * itsLength + 2 * itsWidth; virtual float GetLength() return itsLength; virtual float GetWidth() return itsWidth; private:float itsWidth;float itsLength;void main()Shape * sp;sp = new Circle(5);cout <

20、< "The area of the Circle is " << sp->GetArea () << endl;cout << "The perimeter of the Circle is " << sp->GetPerim () << endl;delete sp;sp = new Rectangle(4,6);cout << "The area of the Rectangle is " << sp->GetArea()

21、 << endl;cout << "The perimeter of the Rectangle is " << sp->GetPerim () << endl;delete sp;程序運行輸出:The area of the Circle is 78.5The perimeter of the Circle is 31.4The area of the Rectangle is 24The perimeter of the Rectangle is 208-10 對Point類重載+(自增)、-(自減)運算符解:#in

22、clude <iostream.h>class Pointpublic:Point& operator+();Point operator+(int);Point& operator-();Point operator-(int);Point() _x = _y = 0; int x() return _x; int y() return _y; private:int _x, _y;Point& Point:operator+()_x+;_y+;return *this;Point Point:operator+(int)Point temp = *thi

23、s;+*this;return temp;Point& Point:operator-()_x-;_y-;return *this;Point Point:operator-(int)Point temp = *this;-*this;return temp;void main()Point A;cout << "A的值為:" << A.x() << " , " << A.y() << endl;A+;cout << "A的值為:" << A.

24、x() << " , " << A.y() << endl;+A;cout << "A的值為:" << A.x() << " , " << A.y() << endl;A-;cout << "A的值為:" << A.x() << " , " << A.y() << endl;-A;cout << "A的值為:"

25、 << A.x() << " , " << A.y() << endl;程序運行輸出:A的值為:0 , 0A的值為:1 , 1A的值為:2 , 2A的值為:1 , 1A的值為:0 , 08-11 定義一個基類BaseClass,從它派生出類DerivedClass,BaseClass有成員函數fn1()、fn2(),fn1()是虛函數,DerivedClass也有成員函數fn1()、fn2(),在主程序中定義一個DerivedClass的對象,分別用BaseClass和DerivedClass的指針來調用fn1()、fn2()

26、,觀察運行結果。解:#include <iostream.h>class BaseClasspublic:virtual void fn1();void fn2();void BaseClass:fn1()cout << "調用基類的虛函數fn1()" << endl;void BaseClass:fn2()cout << "調用基類的非虛函數fn2()" << endl;class DerivedClass : public BaseClasspublic:void fn1();void fn

27、2();void DerivedClass:fn1()cout << "調用派生類的函數fn1()" << endl;void DerivedClass:fn2()cout << "調用派生類的函數fn2()" << endl;void main()DerivedClass aDerivedClass;DerivedClass *pDerivedClass = &aDerivedClass;BaseClass *pBaseClass = &aDerivedClass;pBaseClass-&

28、gt;fn1();pBaseClass->fn2();pDerivedClass->fn1();pDerivedClass->fn2();程序運行輸出:調用派生類的函數fn1()調用基類的非虛函數fn2()調用派生類的函數fn1()調用派生類的函數fn2()8-12 定義一個基類BaseClass,從它派生出類DerivedClass,BaseClass中定義虛析構函數,在主程序中將一個DerivedClass的對象地址賦給一個BaseClass的指針,觀察運行過程。解:#include <iostream.h>class BaseClass public:vir

29、tual BaseClass() cout << "BaseClass()" << endl;class DerivedClass : public BaseClass public:DerivedClass() cout << "DerivedClass()" << endl;void main()BaseClass* bp = new DerivedClass;delete bp;程序運行輸出:DerivedClass()BaseClass()8-13 定義Point類,有成員變量X、Y,為其定義友元函

30、數實現重載+。解:#include <iostream.h>class Pointpublic:Point() X = Y = 0; Point( unsigned x, unsigned y ) X = x; Y = y; unsigned x() return X; unsigned y() return Y; void Print() cout << "Point(" << X << ", " << Y << ")" << endl; frien

31、d Point operator+( Point& pt, int nOffset );friend Point operator+( int nOffset, Point& pt );private:unsigned X;unsigned Y;Point operator+( Point& pt, int nOffset )Point ptTemp = pt;ptTemp.X += nOffset;ptTemp.Y += nOffset;return ptTemp;Point operator+( int nOffset, Point& pt )Point p

32、tTemp = pt;ptTemp.X += nOffset;ptTemp.Y += nOffset;return ptTemp;void main()Point pt( 10, 10 );pt.Print();pt = pt + 5; / Point + intpt.Print();pt = 10 + pt; / int + Pointpt.Print();程序運行輸出:Point(10, 10)Point(15, 15)Point(25, 25)8-14 為某公司設計一個人事管理系統,其基本功能為輸入、編輯、查看和保存公司的人事檔案。職工人事檔案包括姓名、性別、出生日期、婚姻狀況、所在部門

33、、職務和工資。程 序:由于列表框尚未初始化,所以為CEmpDlg類重載OnInitDialog()成員函數(可使用ClassWizard完成),并添加相應代碼:BOOL CEmpDlg:OnInitDialog()CListBox *pLB = (CListBox *)GetDlgItem(IDC_DEPT);pLB->InsertString(-1, "辦公室");pLB->InsertString(-1, "開發部");pLB->InsertString(-1, "生產部");pLB->InsertStri

34、ng(-1, "銷售部");pLB->InsertString(-1, "人事部");return CDialog:OnInitDialog();其中GetDlgItem()為對話框類的成員函數,用于取對話框控件的指針。為項目添加有關自定義的職工類CEmployee。選擇Developer Studio菜單的Insert/New Class選項,調出New Class對話框。在Class Type組合框中選擇Generic(普通類),填寫類名CEmployee,在對話框下方的Base class (es)框中輸入基類CObject。在Workspa

35、ce窗口的Class View中選擇生成的CEmployee類的定義,添加代碼:class CEmployee : public CObjectDECLARE_SERIAL(CEmployee)public:CString m_strName; / 姓名int m_nSex; / 性別COleDateTime m_tBirthdate; / 出生日期BOOL m_bMarried; / 婚否CString m_strDept; / 工作部門CString m_strPosition; / 職務float m_fSalary; / 工資CEmployee()CEmployee& oper

36、ator = (CEmployee& e);virtual CEmployee();virtual void Serialize(CArchive &ar);CEmployee類的對象即為一個職工的檔案,我們用序列化實現文檔的存取,所以要為CEmployee類編寫序列化代碼。這包括DECLARE_SERIAL()宏和IMPLEMENT_SERIAL()宏(在CEmployee類的源代碼文件中),一個沒有參數的構造函數,重載的賦值運算符和Serialize()成員函數。在CEmployee類的源代碼文件中添加以下代碼:IMPLEMENT_SERIAL(CEmployee, COb

37、ject, 1)/ 重載的賦值運算符CEmployee& CEmployee:operator = (CEmployee& e)m_strName = e.m_strName;m_nSex = e.m_nSex;m_tBirthdate = e.m_tBirthdate;m_bMarried = e.m_bMarried;m_strDept = e.m_strDept;m_strPosition = e.m_strPosition;m_fSalary = e.m_fSalary;return *this;/ 序列化函數void CEmployee:Serialize(CArch

38、ive& ar)CObject:Serialize(ar);if(ar.IsStoring()ar << m_strName;ar << m_nSex;ar << m_tBirthdate;ar << m_bMarried;ar << m_strDept;ar << m_strPosition;ar << m_fSalary;elsear >> m_strName;ar >> m_nSex;ar >> m_tBirthdate;ar >> m_bMarri

39、ed;ar >> m_strDept;ar >> m_strPosition;ar >> m_fSalary;然后修改文檔類CMyDocument類定義,添加一個CEmployee類的數組:#include "employee.h"#define MAX_EMPLOYEE 1000class CMy1501Doc : public CDocumentDECLARE_DYNCREATE(CMy1501Doc)public:CEmployee m_empListMAX_EMPLOYEE;int m_nCount;public:virtual

40、BOOL OnNewDocument();virtual void Serialize(CArchive& ar);virtual void DeleteContents();DECLARE_MESSAGE_MAP();為了節省篇幅,這段程序經過刪節,與原來由AppWizard生成的程序有所不同。其中黑體部分為要添加的代碼。注意重載成員函數DeleteContents()可以手工進行,也可以通過ClassWizard進行。Serialize()和DeleteContents()兩個成員函數的代碼如下:void CMy1501Doc:Serialize(CArchive& ar)

41、if(ar.IsStoring()ar << m_nCount;elsear >> m_nCount;for(int i=0; i<m_nCount; i+)m_empListi.Serialize(ar);void CMy1501Doc:DeleteContents()m_nCount = 0; / 在打開文件和建立新文件時將數組大小置0CDocument:DeleteContents();即在文檔類的Serialize()函數中,數據的序列化工作是通過調用Cemployee類的Serialize()函數實現的。實際上,要為本程序添加的大部分代碼均在視圖類中。首

42、先在視圖類CmyView類的定義中添加一個用于記錄當前操作的是哪個記錄的數據成員:int m_nCurrEmp;并為視圖類重載OnInitialUpdate()成員函數,在其中初始化該變量:void CMy1501View:OnInitialUpdate()CView:OnInitialUpdate();m_nCurrEmp = 0;Invalidate();視圖類的OnDraw()成員函數用于顯示正在操作的職工檔案:void CMy1501View:OnDraw(CDC* pDC)CMy1501Doc* pDoc = GetDocument();ASSERT_VALID(pDoc);/ 顯示

43、職工人數和當前職工編號CString s;s.Format("職工人數: %d", pDoc->m_nCount);pDC->SetTextColor(RGB(255, 0, 0);pDC->TextOut( 40, 40, s);s.Format("職工編號: %d", m_nCurrEmp+1);pDC->TextOut(340, 40, s);pDC->MoveTo( 40, 70);pDC->LineTo(600, 70);/ 如果檔案非空, 顯示當前記錄if(pDoc->m_nCount > 0)

44、/ 顯示欄目名稱pDC->SetTextColor(RGB(0, 0, 0);pDC->TextOut(140, 90, "姓 名:");pDC->TextOut(140, 130, "性 別:");pDC->TextOut(140, 170, "出生日期: ");pDC->TextOut(140, 210, "婚姻狀態:");pDC->TextOut(140, 250, "部 門:");pDC->TextOut(140, 290, "職 務:

45、");pDC->TextOut(140, 330, "工 資:");/ 顯示欄目內容pDC->SetTextColor(RGB(0, 0, 255);pDC->TextOut(300, 90, pDoc->m_empListm_nCurrEmp.m_strName);if(pDoc->m_empListm_nCurrEmp.m_nSex=0)pDC->TextOut(300, 130, "男");elsepDC->TextOut(300, 130, "女");s = pDoc->

46、;m_empListm_nCurrEmp.m_tBirthdate.Format("%Y.%m.%d");pDC->TextOut(300, 170, s);if(pDoc->m_empListm_nCurrEmp.m_bMarried)pDC->TextOut(300, 210, "已婚");elsepDC->TextOut(300, 210, "未婚");pDC->TextOut(300, 250, pDoc->m_empListm_nCurrEmp.m_strDept);pDC->Tex

47、tOut(300, 290, pDoc->m_empListm_nCurrEmp.m_strPosition);s.Format("%8.2f", pDoc->m_empListm_nCurrEmp.m_fSalary);pDC->TextOut(300, 330, s);在編輯資源時,我們框架窗口添加了5個菜單選項,并將對應的消息響應函數映射到了視圖類中。這些消息響應函數的代碼如下:void CMy1501View:OnAppend()CMy1501Doc* pDoc = GetDocument();ASSERT_VALID(pDoc);CEmpDlg

48、dlg;if(dlg.DoModal() = IDOK)pDoc->m_nCount+;m_nCurrEmp = pDoc->m_nCount-1;pDoc->m_empListm_nCurrEmp.m_strName = dlg.m_strName;pDoc->m_empListm_nCurrEmp.m_nSex = dlg.m_nSex;pDoc->m_empListm_nCurrEmp.m_tBirthdate = dlg.m_tBirthdate;pDoc->m_empListm_nCurrEmp.m_bMarried = dlg.m_bMarrie

49、d;pDoc->m_empListm_nCurrEmp.m_strDept = dlg.m_strDept;pDoc->m_empListm_nCurrEmp.m_strPosition = dlg.m_strPosition;pDoc->m_empListm_nCurrEmp.m_fSalary = dlg.m_fSalary;pDoc->SetModifiedFlag();Invalidate();/ 刪除當前記錄void CMy1501View:OnDelete()CMy1501Doc* pDoc = GetDocument();ASSERT_VALID(pDoc

50、);if(pDoc->m_nCount)for(int i=m_nCurrEmp; i<pDoc->m_nCount-1; i+)pDoc->m_empListi = pDoc->m_empListi+1;pDoc->m_nCount-;if(m_nCurrEmp > pDoc->m_nCount-1)m_nCurrEmp = pDoc->m_nCount-1;pDoc->SetModifiedFlag();Invalidate();/ 編輯當前記錄void CMy1501View:OnEdit()CMy1501Doc* pDoc =

51、 GetDocument();ASSERT_VALID(pDoc);if(pDoc->m_nCount)CEmpDlg dlg;dlg.m_strName = pDoc->m_empListm_nCurrEmp.m_strName;dlg.m_nSex = pDoc->m_empListm_nCurrEmp.m_nSex;dlg.m_tBirthdate = pDoc->m_empListm_nCurrEmp.m_tBirthdate;dlg.m_bMarried = pDoc->m_empListm_nCurrEmp.m_bMarried;dlg.m_strDe

52、pt = pDoc->m_empListm_nCurrEmp.m_strDept;dlg.m_strPosition = pDoc->m_empListm_nCurrEmp.m_strPosition;dlg.m_fSalary = pDoc->m_empListm_nCurrEmp.m_fSalary;if(dlg.DoModal() = IDOK)pDoc->m_empListm_nCurrEmp.m_strName = dlg.m_strName;pDoc->m_empListm_nCurrEmp.m_nSex = dlg.m_nSex;pDoc->m

53、_empListm_nCurrEmp.m_tBirthdate = dlg.m_tBirthdate;pDoc->m_empListm_nCurrEmp.m_bMarried = dlg.m_bMarried;pDoc->m_empListm_nCurrEmp.m_strDept = dlg.m_strDept;pDoc->m_empListm_nCurrEmp.m_strPosition = dlg.m_strPosition;pDoc->m_empListm_nCurrEmp.m_fSalary = dlg.m_fSalary;pDoc->SetModifie

54、dFlag();Invalidate();/ 查看后一記錄void CMy1501View:OnNext()CMy1501Doc* pDoc = GetDocument();ASSERT_VALID(pDoc);if(pDoc->m_nCount > 1)if(m_nCurrEmp = pDoc->m_nCount-1)m_nCurrEmp = 0;elsem_nCurrEmp+;Invalidate();/ 查看前一記錄void CMy1501View:OnPrev()CMy1501Doc* pDoc = GetDocument();ASSERT_VALID(pDoc);i

55、f(pDoc->m_nCount > 1)if(m_nCurrEmp = 0)m_nCurrEmp = pDoc->m_nCount-1;elsem_nCurrEmp-;Invalidate();8-15 用基于對話框的應用程序結構實現例14-5的彩色吹泡泡程序。由于對話框本身結構簡單,沒有明顯的客戶區,顏色也不醒目,所以我們在對話框上自行建立一個矩形區域作為吹泡泡的客戶區,并通過一個“顏色設置”按鈕來設置泡泡的顏色。說 明:用AppWizard建立一個基于對話框的應用程序框架(參看15.4:“用AppWizard生成基于對話框的應用程序”),所有設置均使用缺省值。使用對話框

56、模板編輯器編輯作為主界面窗口的對話框模板,將其上的靜態文本控件和“Cancel”按鈕刪除,將“OK”按鈕的Caption設置為“完成”,并將對話框大小調整為400×300左右。為對話框模板添加一個Picture控件,將其Type設置為Frame,Color設置為Black,并設置Sunken屬性(在Styles選項卡中)。調整其位置為(7,7),大小為287×287。這個框中即為自定義的吹泡泡客戶區,所有的吹泡泡活動均在該區域中進行。為對話框模板添加一個按鈕,將其ID改為IDC_COLOR,Caption改為“顏色設置”。使用ClassWizard為對話框類添加一個鼠標左鍵

57、消息響應函數OnLButtonDown()和一個按鈕命令消息響應函數OnColor()。程 序:在對話框類的頭文件前面添加一行:#define MAX_BUBBLE 250并在對話框類定義中添加存放泡泡的幾何參數和顏色的數組數據成員:CRect m_rectBubbleMAX_BUBBLE;COLORREF m_colorBubbleMAX_BUBBLE;int m_nBubbleCount;以及一個存放自定義客戶區矩形的數據成員和一個存放當前泡泡顏色設置的數據成員:CRect m_rectClient;COLORREF m_colorCurrent;修改對話框類的OnInitDialog()

58、成員函數,添加計算自定義客戶區位置和大小的代碼,并將泡泡的數目初始化為0:BOOL CMyDlg:OnInitDialog()CDialog:OnInitDialog();CStatic *pST = (CStatic *)GetDlgItem(IDC_CLIENT);pST->GetWindowRect(&m_rectClient);ScreenToClient(&m_rectClient);m_nBubbleCount = 0;return TRUE;修改OnPaint()成員函數,添加畫出泡泡的有關代碼:void CMyDlg:OnPaint()CPaintDC dc(this);CRgn rgn;rgn.CreateRectRgnIndirect(&m_rectClient); / 生成一個區域對象dc.SelectClipRgn(&rgn); / 選擇區域dc.Rectangle(m_rectClient); / 將客戶區背景設置CBrush brushNew, *pbrushOld; / 白色for(int i=0; i<m_nBubbleCount; i+)brushNe

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論