亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? apd.htm

?? good book for learning c++ standard language
?? HTM
?? 第 1 頁 / 共 5 頁
字號:
<PRE><FONT COLOR="#0066FF"> class Node
 {
 public:
    Node ();
    Node (int);
    ~Node();
    void SetNext(Node * node) { itsNext = node; }
    Node * GetNext() const { return itsNext; }
    int GetVal() const { return itsVal; }
    void Insert(Node *);
    void Display();
 private:
    int itsVal;
    Node * itsNext;
 };
</FONT></PRE>

<DL>
	<DD><B>4.</B> BUG BUSTERS: What is wrong with this code fragment?
</DL>

<PRE><FONT COLOR="#0066FF">unsigned short SomeArray[5][4];
for (int i = 0; i&lt;4; i++)
     for (int j = 0; j&lt;5; j++)
          SomeArray[i][j] = i+j;
</FONT></PRE>

<DL>
	<DD>The array is 5 elements by 4 elements, but the code initializes 4x5.<BR>
	<B><BR>
	5.</B> BUG BUSTERS: What is wrong with this code fragment?
</DL>

<PRE><FONT COLOR="#0066FF">unsigned short SomeArray[5][4];
for (int i = 0; i&lt;=5; i++)
     for (int j = 0; j&lt;=4; j++)
          SomeArray[i][j] = 0;
</FONT></PRE>

<DL>
	<DD>You wanted to write <TT>i&lt;5</TT>, but you wrote <TT>i&lt;=5</TT> instead.
	The code will run when <TT>i == 5</TT> and <TT>j == 4</TT>, but there is no such
	element as <TT>SomeArray[5][4]</TT>.
</DL>

<H3 ALIGN="CENTER"></H3>
<H3><A NAME="Heading36"></A><FONT COLOR="#000077">Day 12</FONT></H3>
<H4 ALIGN="CENTER"><A NAME="Heading37"></A><FONT COLOR="#000077">Quiz</FONT></H4>

<DL>
	<DD><B>1. What is a v-table?<BR>
	</B><BR>
	A v-table, or virtual function table, is a common way for compilers to manage virtual
	functions in C++. The table keeps a list of the addresses of all the virtual functions
	and, depending on the runtime type of the object pointed to, invokes the right function.<BR>
	<BR>
	<B>2. What is a virtual destructor?<BR>
	</B><BR>
	A destructor of any class can be declared to be virtual. When the pointer is deleted,
	the runtime type of the object will be assessed and the correct derived destructor
	invoked.<BR>
	<BR>
	<B>3. How do you show the declaration of a virtual constructor?<BR>
	</B><BR>
	There are no virtual constructors.<BR>
	<BR>
	<B>4. How can you create a virtual copy constructor?<BR>
	</B><BR>
	By creating a virtual method in your class, which itself calls the copy constructor.<BR>
	<BR>
	<B>5. How do you invoke a base member function from a derived class in which you've
	overridden that function?</B>
</DL>

<PRE><FONT COLOR="#0066FF">Base::FunctionName();
</FONT></PRE>

<DL>
	<DD><B>6. How do you invoke a base member function from a derived class in which
	you have not <BR>
	overridden that function?</B>
</DL>

<PRE><FONT COLOR="#0066FF">FunctionName();
</FONT></PRE>

<DL>
	<DD><B>7. If a base class declares a function to be virtual, and a derived class
	does not use the term <TT>virtual</TT> when overriding that class, is it still virtual
	when inherited by a third-generation class?</B><BR>
	<BR>
	Yes, the virtuality is inherited and cannot be turned off.<BR>
	<BR>
	<B>8. What is the <TT>protected</TT> keyword used for?</B><BR>
	<TT><BR>
	protected</TT> members are accessible to the member functions of derived objects.
</DL>

<H4 ALIGN="CENTER"><A NAME="Heading38"></A><FONT COLOR="#000077">Exercises</FONT></H4>

<DL>
	<DD><B>1. </B>Show the declaration of a virtual function taking an integer parameter
	and returning <TT>void</TT>.
</DL>

<PRE><FONT COLOR="#0066FF">virtual void SomeFunction(int);
</FONT></PRE>

<DL>
	<DD><B>2.</B> Show the declaration of a class <TT>Square</TT>, which derives from
	<TT>Rectangle</TT>, which in turn derives from <TT>Shape</TT>.
</DL>

<PRE><FONT COLOR="#0066FF">class Square : public Rectangle
{};
</FONT></PRE>

<DL>
	<DD><B>3.</B> If, in Exercise 2, <TT>Shape</TT> takes no parameters, <TT>Rectangle</TT>
	takes two (<TT>length</TT> and <TT>width</TT>), and <TT>Square</TT> takes only one
	(<TT>length</TT>), show the constructor initialization for <TT>Square</TT>.
</DL>

<PRE><FONT COLOR="#0066FF">Square::Square(int length):
     Rectangle(length, length){}
</FONT></PRE>

<DL>
	<DD><B>4.</B> Write a virtual copy constructor for the class <TT>Square</TT> (from
	the preceding question).
</DL>

<PRE><FONT COLOR="#0066FF">class Square
      {
         public:
         // ...
         virtual Square * clone() const { return new Square(*this); }
       // ...
     };
</FONT></PRE>

<DL>
	<DD><B>5.</B> BUG BUSTERS: What is wrong with this code snippet?
</DL>

<PRE><FONT COLOR="#0066FF">void SomeFunction (Shape);
Shape * pRect = new Rectangle;
SomeFunction(*pRect);
</FONT></PRE>

<DL>
	<DD>Perhaps nothing. <TT>SomeFunction</TT> expects a <TT>Shape</TT> object. You've
	passed it a <TT>Rectangle</TT> &quot;sliced&quot; down to a <TT>Shape</TT>. As long
	as you don't need any of the <TT>Rectangle</TT> parts, this will be fine. If you
	do need the <TT>Rectangle</TT> parts, you'll need to change <TT>SomeFunction</TT>
	to take a pointer or a reference to a <TT>Shape</TT>.<BR>
	<B><BR>
	6.</B> BUG BUSTERS: What is wrong with this code snippet?
</DL>

<PRE><FONT COLOR="#0066FF">class Shape()
{
public:
     Shape();
     virtual ~Shape();
     virtual Shape(const Shape&amp;);
};
</FONT></PRE>

<DL>
	<DD>You can't declare a copy constructor to be virtual.
</DL>

<H3 ALIGN="CENTER"></H3>
<H3><A NAME="Heading39"></A><FONT COLOR="#000077">Day 13</FONT></H3>
<H4 ALIGN="CENTER"><A NAME="Heading40"></A><FONT COLOR="#000077">Quiz</FONT></H4>

<DL>
	<DD><B>1. What is a down cast?<BR>
	</B><BR>
	A down cast (also called &quot;casting down&quot;) is a declaration that a pointer
	to a base class is to be treated as a pointer to a derived class.<BR>
	<BR>
	<B>2. What is the v-ptr?<BR>
	</B><BR>
	The v-ptr, or virtual-function pointer, is an implementation detail of virtual functions.
	Each object in a class with virtual functions has a v-ptr, which points to the virtual
	function table for that class.<BR>
	<BR>
	<B>3. If a round rectangle has straight edges and rounded corners, your <TT>RoundRect</TT>
	class inherits both from <TT>Rectangle</TT> and from <TT>Circle</TT>, and they in
	turn both inherit from <TT>Shape</TT>, how many <TT>Shape</TT>s are created when
	you create a <TT>RoundRect</TT>?</B><BR>
	<BR>
	If neither class inherits using the keyword <TT>virtual</TT>, two <TT>Shapes</TT>
	are created: one for <TT>Rectangle</TT> and one for <TT>Shape</TT>. If the keyword
	<TT>virtual</TT> is used for both classes, only one shared <TT>Shape</TT> is created.<BR>
	<BR>
	<B>4. If <TT>Horse</TT> and <TT>Bird</TT> inherit <TT>virtual</TT> <TT>public</TT>
	from <TT>Animal</TT>, do their constructors initialize the <TT>Animal</TT> constructor?
	If <TT>Pegasus</TT> inherits from both <TT>Horse</TT> and <TT>Bird</TT>, how does
	it initialize <TT>Animal</TT>'s constructor?</B><BR>
	<BR>
	Both <TT>Horse</TT> and <TT>Bird</TT> initialize their base class, <TT>Animal</TT>,
	in their constructors. <TT>Pegasus</TT> does as well, and when a <TT>Pegasus</TT>
	is created, the <TT>Horse</TT> and <TT>Bird</TT> initializations of <TT>Animal</TT>
	are ignored.<BR>
	<B><BR>
	5. Declare a class <TT>Vehicle</TT> and make it an abstract data type.</B>
</DL>

<PRE><FONT COLOR="#0066FF">class Vehicle
{
     virtual void Move() = 0;
}
</FONT></PRE>

<DL>
	<DD><B>6. If a base class is an ADT, and it has three pure virtual functions, how
	many of these functions must be overridden in its derived classes?</B><BR>
	<BR>
	None must be overridden unless you want to make the class non-abstract, in which
	case all three must be overridden.
</DL>

<H4 ALIGN="CENTER"><A NAME="Heading41"></A><FONT COLOR="#000077">Exercises</FONT></H4>

<DL>
	<DD><B>1.</B> Show the declaration for a class <TT>JetPlane</TT>, which inherits
	from <TT>Rocket</TT> and <TT>Airplane</TT>.
</DL>

<PRE><FONT COLOR="#0066FF">class JetPlane : public Rocket, public Airplane
</FONT></PRE>

<DL>
	<DD><B>2. </B>Show the declaration for <TT>747</TT>, which inherits from the <TT>JetPlane</TT>
	class described in Exercise 1.
</DL>

<PRE><FONT COLOR="#0066FF">class 747 : public JetPlane
</FONT></PRE>

<DL>
	<DD><B>3.</B> Show the declarations for the classes <TT>Car</TT> and <TT>Bus</TT>,
	which each derive from the class <TT>Vehicle</TT>. Make <TT>Vehicle</TT> an ADT with
	two pure virtual functions. Make <TT>Car</TT> and <TT>Bus</TT> not be ADTs.
</DL>

<PRE><FONT COLOR="#0066FF">class Vehicle
{
     virtual void Move() = 0;
     virtual void Haul() = 0;
};

class Car : public Vehicle
{
     virtual void Move();
     virtual void Haul();
};

class Bus : public Vehicle
{
     virtual void Move();
     virtual void Haul();
};
</FONT></PRE>

<DL>
	<DD><B>4. </B>Modify the program in Exercise 1 so that <TT>Car</TT> is an ADT, and
	derive <TT>SportsCar</TT> and <TT>Coupe</TT> from <TT>Car</TT>. In the <TT>Car</TT>
	class, provide an implementation for one of the pure virtual functions in <TT>Vehicle</TT>
	and make it non-pure.
</DL>

<PRE><FONT COLOR="#0066FF">class Vehicle
{
     virtual void Move() = 0;
     virtual void Haul() = 0;
};

class Car : public Vehicle
{
     virtual void Move();
};

class Bus : public Vehicle
{
     virtual void Move();
     virtual void Haul();
};

class SportsCar : public Car
{
     virtual void Haul();
};

class Coupe : public Car
{
     virtual void Haul();
};
</FONT></PRE>
<H3 ALIGN="CENTER"><FONT COLOR="#0066FF"></FONT></H3>
<H3><A NAME="Heading42"></A><FONT COLOR="#000077">Day 14</FONT></H3>
<H4 ALIGN="CENTER"><A NAME="Heading43"></A><FONT COLOR="#000077">Quiz</FONT></H4>

<DL>
	<DD><B>1. Can static member variables be private?</B><BR>
	<BR>
	Yes. They are member variables, and their access can be controlled like any other.
	If they are private, they can be accessed only by using member functions or, more
	commonly, static member functions.<BR>
	<B><BR>
	2. Show the declaration for a static member variable.</B>
</DL>

<PRE><FONT COLOR="#0066FF">static int itsStatic;
</FONT></PRE>

<DL>
	<DD><B>3. Show the declaration for a static function pointer.</B>
</DL>

<PRE><FONT COLOR="#0066FF">static int SomeFunction();
</FONT></PRE>

<DL>
	<DD><B>4. Show the declaration for a pointer <TT>to</TT> function returning <TT>long</TT>
	and taking an integer parameter.</B>
</DL>

<PRE><FONT COLOR="#0066FF">long (* function)(int);
</FONT></PRE>

<DL>
	<DD><B>5. Modify the pointer in Exercise 4 to be a pointer to member function of
	class <TT>Car</TT></B>
</DL>

<PRE><FONT COLOR="#0066FF">long ( Car::*function)(int);
</FONT></PRE>

<DL>
	<DD><B>6. Show the declaration for an array of 10 pointers as defined in Exercise
	5.</B>
</DL>

<PRE><FONT COLOR="#0066FF">(long ( Car::*function)(int) theArray [10];
</FONT></PRE>
<H4 ALIGN="CENTER"><A NAME="Heading44"></A><FONT COLOR="#000077">Exercises</FONT></H4>

<DL>
	<DD><B>1.</B> Write a short program declaring a class with one member variable and
	one static member variable. Have the constructor initialize the member variable and
	increment the static member variable. Have the destructor decrement the member variable.
</DL>

<PRE><FONT COLOR="#0066FF">1:     class myClass
2:     {
3:     public:
4:        myClass();
5:        ~myClass();
6:     private:
7:        int itsMember;
8:        static int itsStatic;
9:     };
10:
11:    myClass::myClass():
12:     itsMember(1)
13:    {
14:       itsStatic++;
15:    }
16:
17:    myClass::~myClass()
18:    {
19:       itsStatic--;
20:    }
21:
22:    int myClass::itsStatic = 0;
23:
24:    int main()
25:    {}
</FONT></PRE>

<DL>
	<DD><B>2. </B>Using the program from Exercise 1, write a short driver program that
	makes three objects and then displays their member variables and the static member
	variable. Then destroy each object and show the effect on the static member variable.
</DL>

<PRE><FONT COLOR="#0066FF">1:     #include &lt;iostream.h&gt;
2:
3:     class myClass
4:     {
5:     public:
6:        myClass();
7:        ~myClass();
8:        void ShowMember();
9:        void ShowStatic();
10:    private:
11:       int itsMember;
12:       static int itsStatic;
13:    };
14:
15:    myClass::myClass():
16:     itsMember(1)
17:    {
18:       itsStatic++;
19:    }
20:
21:    myClass::~myClass()
22:    {
23:       itsStatic--;
24:       cout &lt;&lt; &quot;In destructor. ItsStatic: &quot; &lt;&lt; itsStatic &lt;&lt; endl;
25:    }
26:
27:    void myClass::ShowMember()
28:    {
29:       cout &lt;&lt; &quot;itsMember: &quot; &lt;&lt; itsMember &lt;&lt; endl;
30:    }
31:
32:    void myClass::ShowStatic()

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一本久久精品一区二区| 一区二区免费在线播放| 中文字幕成人网| 久久爱www久久做| 91精品国产91久久久久久一区二区| 综合色中文字幕| caoporn国产精品| 国产色产综合产在线视频| 精品一区二区三区久久久| 在线播放91灌醉迷j高跟美女 | 亚洲欧美色综合| 成人av午夜影院| 国产精品美女久久久久久2018| 麻豆91在线看| 国产日韩精品一区二区三区| 久久国产日韩欧美精品| www国产成人| 粉嫩aⅴ一区二区三区四区 | 日本道精品一区二区三区| 成人欧美一区二区三区在线播放| 91在线观看视频| 日韩精品一级中文字幕精品视频免费观看 | 激情六月婷婷综合| 欧美激情一区不卡| 在线视频综合导航| 日韩福利电影在线观看| 精品久久人人做人人爰| 91捆绑美女网站| 日本女人一区二区三区| 欧美国产欧美综合| 在线观看av不卡| 国产精品一区二区黑丝| 国产三级三级三级精品8ⅰ区| 99re66热这里只有精品3直播| 亚洲自拍与偷拍| 国产日韩精品一区二区三区在线| 色婷婷精品久久二区二区蜜臀av| 免费高清在线一区| 一区二区三区在线观看动漫| 精品91自产拍在线观看一区| 91免费观看在线| 国产成人av电影| 天堂成人国产精品一区| 亚洲欧美激情小说另类| 国产欧美日韩久久| 欧美一级片在线看| 欧美精品在线视频| 欧美在线三级电影| 91小视频在线免费看| 国产精品影音先锋| 国产美女娇喘av呻吟久久| 爽爽淫人综合网网站| 水野朝阳av一区二区三区| 亚洲尤物在线视频观看| 亚洲欧洲制服丝袜| 一区二区三区成人在线视频| 国产偷国产偷亚洲高清人白洁| 日韩欧美国产午夜精品| 日韩精品一区二区三区视频在线观看| 91极品视觉盛宴| 欧美午夜影院一区| 制服丝袜亚洲网站| 日韩欧美一二区| 久久精品视频免费| 26uuu色噜噜精品一区| 中文字幕精品一区二区三区精品| 精品国产91洋老外米糕| 中文字幕欧美三区| 亚洲男帅同性gay1069| 视频一区二区三区中文字幕| 午夜国产精品一区| 国产精品一区二区免费不卡 | 亚洲视频1区2区| 午夜精品久久久久久久蜜桃app| 久久精品欧美一区二区三区麻豆| 91麻豆精品一区二区三区| 国产suv精品一区二区三区| 国产精品白丝av| 欧美亚洲丝袜传媒另类| 日韩欧美精品在线视频| 亚洲欧美在线另类| 奇米色一区二区| 粉嫩嫩av羞羞动漫久久久| 在线这里只有精品| 久久夜色精品国产噜噜av| 一区二区三区电影在线播| 精品无人区卡一卡二卡三乱码免费卡 | 7777精品伊人久久久大香线蕉的 | 中文字幕一区二区三区四区不卡 | 老汉av免费一区二区三区| 成人免费观看视频| 精品理论电影在线| 亚洲综合在线视频| 国产在线不卡一区| 日韩免费电影一区| 婷婷成人激情在线网| 97精品国产露脸对白| 久久亚洲欧美国产精品乐播| 人人爽香蕉精品| 欧美日韩午夜精品| 天天色天天爱天天射综合| 在线观看成人免费视频| 亚洲最快最全在线视频| 91久久人澡人人添人人爽欧美| 亚洲人一二三区| 欧美无人高清视频在线观看| 亚洲综合精品自拍| 在线精品亚洲一区二区不卡| 亚洲一区二区影院| 欧美日韩和欧美的一区二区| 午夜国产精品一区| 日韩免费电影一区| 99精品视频一区二区三区| 国产精品久久久久久久久免费桃花 | 99精品视频在线播放观看| 一区二区三区.www| 欧美精品色一区二区三区| 亚洲一区二区3| 日韩一区二区免费视频| 久久精品国产久精国产爱| 国产午夜精品一区二区| 色综合久久久久久久久久久| 一区二区三区四区蜜桃| 欧美一区二区高清| www.色精品| 天天综合天天综合色| 日本一区二区三级电影在线观看| 一本到高清视频免费精品| 男女性色大片免费观看一区二区 | 国产精品久久久久天堂| 欧美日韩成人综合天天影院| 极品销魂美女一区二区三区| 亚洲欧美在线视频| 久久久久久99久久久精品网站| 91丝袜高跟美女视频| 国产成人在线免费| 天天影视色香欲综合网老头| 国产精品毛片久久久久久| 日韩精品专区在线影院重磅| 在线观看视频一区二区| 成人免费不卡视频| 国产尤物一区二区在线| 日日夜夜免费精品| 亚洲成av人片一区二区梦乃| 国产欧美一区二区三区在线看蜜臀| 色就色 综合激情| 国产经典欧美精品| 国产伦精品一区二区三区免费迷 | 欧美精品九九99久久| 另类小说一区二区三区| 午夜精品久久久久久久 | 欧美精品一区二区三区很污很色的| 一本久久a久久精品亚洲| 成人听书哪个软件好| 国产福利一区在线| 韩国三级电影一区二区| 国产综合色产在线精品| 国产伦精品一区二区三区免费迷| 美女一区二区视频| 国内一区二区在线| 国产做a爰片久久毛片| 成人免费av资源| 91天堂素人约啪| 在线亚洲免费视频| 日韩一区二区电影| ww久久中文字幕| 国产精品网曝门| 亚洲成人av福利| 国产综合久久久久久鬼色| 99热在这里有精品免费| 在线视频你懂得一区二区三区| 欧美一区二区久久| 国产精品欧美一区喷水| 亚洲成人免费av| 国产麻豆视频一区| 欧美色综合久久| 国产夜色精品一区二区av| 亚洲网友自拍偷拍| 国产高清在线精品| 91麻豆精品国产自产在线| 国产精品久久午夜| 精品中文字幕一区二区小辣椒| 不卡av电影在线播放| 欧美一级在线观看| 亚洲欧洲综合另类| 成人妖精视频yjsp地址| 日韩欧美黄色影院| 午夜视频在线观看一区二区三区 | 亚洲成精国产精品女| 99精品国产99久久久久久白柏| 欧美精品一区二区不卡| 婷婷开心久久网| 欧美性生交片4| 一区二区三区四区视频精品免费 | 欧美日韩亚洲综合在线| 综合亚洲深深色噜噜狠狠网站| 国产九色sp调教91| 亚洲精品一区二区三区99| 另类欧美日韩国产在线| 欧美一区二区三区日韩视频|