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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? apd.htm

?? good book for learning c++ standard language
?? HTM
?? 第 1 頁 / 共 5 頁
字號:
9:        private:
10:          int itsAge;
11:    };
12:
13:    CAT & MakeCat(int age);
14:    int main()
15:    {
16:       int age = 7;
17:       CAT Boots = MakeCat(age);
18:       cout << "Boots is " << Boots.GetAge() << " years old\n";
19:     return 0;
20:    }
21:
22:    CAT & MakeCat(int age)
23:    {
24:       CAT * pCat = new CAT(age);
25:       return *pCat;
26:    }
</FONT></PRE>

<DL>
	<DD><TT>MakeCat</TT> returns a reference to the <TT>CAT</TT> created on the free
	store. There is no way to free that memory, and this produces a memory leak.<BR>
	<BR>
	<B>9.</B> Fix the program from Exercise 8.
</DL>

<PRE><FONT COLOR="#0066FF">1:     #include &lt;iostream.h&gt;
2:
3:     class CAT
4:     {
5:        public:
6:           CAT(int age) { itsAge = age; }
7:           ~CAT(){}
8:           int GetAge() const { return itsAge;}
9:        private:
10:          int itsAge;
11:    };
12:
13:    CAT * MakeCat(int age);
14:    int main()
15:    {
16:       int age = 7;
17:       CAT * Boots = MakeCat(age);
18:       cout &lt;&lt; &quot;Boots is &quot; &lt;&lt; Boots-&gt;GetAge() &lt;&lt; &quot; years old\n&quot;;
19:       delete Boots;
20:     return 0;
21:    }
22:
23:    CAT * MakeCat(int age)
24:    {
25:       return new CAT(age);
26:    }
</FONT></PRE>
<H3 ALIGN="CENTER"><FONT COLOR="#0066FF"></FONT></H3>
<H3><A NAME="Heading30"></A><FONT COLOR="#000077">Day 10</FONT></H3>
<H4 ALIGN="CENTER"><A NAME="Heading31"></A><FONT COLOR="#000077">Quiz</FONT></H4>

<DL>
	<DD><B>1. When you overload member functions, in what ways must they differ?<BR>
	</B><BR>
	Overloaded member functions are functions in a class that share a name but differ
	in the number or type of their parameters.<BR>
	<B>2. What is the difference between a declaration and a definition?<BR>
	</B><BR>
	A definition sets aside memory, but a declaration does not. Almost all declarations
	are definitions; the major exceptions are class declarations, function prototypes,
	and <TT>typedef</TT> statements.<BR>
	<B><BR>
	3. When is the copy constructor called?<BR>
	</B><BR>
	Whenever a temporary copy of an object is created. This happens every time an object
	is passed by value.<BR>
	<BR>
	<B>4. When is the destructor called?<BR>
	</B><BR>
	The destructor is called each time an object is destroyed, either because it goes
	out of scope or because you call <TT>delete</TT> on a pointer pointing to it.<BR>
	<B><BR>
	5. How does the copy constructor differ from the assignment operator (<TT>=</TT>)?<BR>
	</B><BR>
	The assignment operator acts on an existing object; the copy constructor creates
	a new one.<BR>
	<B><BR>
	6. What is the <TT>this</TT> pointer?<BR>
	</B><BR>
	The <TT>this</TT> pointer is a hidden parameter in every member function that points
	to the object itself.<BR>
	<BR>
	<B>7. How do you differentiate between overloading the prefix and postfix increments?<BR>
	</B><BR>
	The prefix operator takes no parameters. The postfix operator takes a single <TT>int</TT>
	parameter, which is used as a signal to the compiler that this is the postfix variant.<BR>
	<BR>
	<B>8. Can you overload the operator<TT>+</TT> for <TT>short</TT> integers?<BR>
	</B><BR>
	No, you cannot overload any operator for built-in types.<BR>
	<BR>
	<B>9. Is it legal in C++ to overload <TT>operator++</TT> so that it decrements a
	value in your class?<BR>
	</B><BR>
	It is legal, but it is a bad idea. Operators should be overloaded in a way that is
	likely to be readily understood by anyone reading your code.<BR>
	<BR>
	<B>10. What return value must conversion operators have in their declaration?<BR>
	</B><BR>
	None. Like constructors and destructors, they have no return values.
</DL>

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

<DL>
	<DD><B>1.</B> Write a <TT>SimpleCircle</TT> class declaration (only) with one member
	variable: <TT>itsRadius</TT>. Include a default constructor, a destructor, and accessor
	methods for <TT>itsRadius</TT>.
</DL>

<PRE><FONT COLOR="#0066FF">class SimpleCircle
{
public:
     SimpleCircle();
     ~SimpleCircle();
     void SetRadius(int);
     int GetRadius();
private:
     int itsRadius;
};
</FONT></PRE>

<DL>
	<DD><B>2.</B> Using the class you created in Exercise 1, write the implementation
	of the default constructor, initializing <TT>itsRadius</TT> with the value <TT>5</TT>.
</DL>

<PRE><FONT COLOR="#0066FF">SimpleCircle::SimpleCircle():
itsRadius(5)
{}
</FONT></PRE>

<DL>
	<DD><B>3.</B> Using the same class, add a second constructor that takes a value as
	its parameter and assigns that value to <TT>itsRadius</TT>.
</DL>

<PRE><FONT COLOR="#0066FF">SimpleCircle::SimpleCircle(int radius):
itsRadius(radius)
{}
</FONT></PRE>

<DL>
	<DD><B>4. </B>Create a prefix and postfix increment operator for your <TT>SimpleCircle</TT>
	class that increments <TT>itsRadius</TT>.
</DL>

<PRE><FONT COLOR="#0066FF">const SimpleCircle&amp; SimpleCircle::operator++()
{
     ++(itsRadius);
     return *this;
}

// Operator ++(int) postfix. 
// Fetch then increment
const SimpleCircle SimpleCircle::operator++ (int)
{
// declare local SimpleCircle and initialize to value of *this
    SimpleCircle temp(*this);  
    ++(itsRadius);
    return temp;  
}
</FONT></PRE>

<DL>
	<DD><B>5.</B> Change <TT>SimpleCircle</TT> to store <TT>itsRadius</TT> on the free
	store, and fix the existing methods.
</DL>

<PRE><FONT COLOR="#0066FF">class SimpleCircle
{
public:
     SimpleCircle();
     SimpleCircle(int);
     ~SimpleCircle();
     void SetRadius(int);
     int GetRadius();
     const SimpleCircle&amp; operator++();
     const SimpleCircle operator++(int);
private:
     int *itsRadius;
};


SimpleCircle::SimpleCircle()
{itsRadius = new int(5);}

SimpleCircle::SimpleCircle(int radius)
{itsRadius = new int(radius);}

const SimpleCircle&amp; SimpleCircle::operator++()
{
     ++(itsRadius);
     return *this;
}

// Operator ++(int) postfix. 
// Fetch then increment
const SimpleCircle SimpleCircle::operator++ (int)
{
// declare local SimpleCircle and initialize to value of *this
    SimpleCircle temp(*this);  
    ++(itsRadius);
    return temp;  
}
</FONT></PRE>

<DL>
	<DD><B>6. </B>Provide a copy constructor for <TT>SimpleCircle</TT>.
</DL>

<PRE><FONT COLOR="#0066FF">SimpleCircle::SimpleCircle(const SimpleCircle &amp; rhs)
{
     int val = rhs.GetRadius();
     itsRadius = new int(val);
}
</FONT></PRE>

<DL>
	<DD><B>7.</B> Provide an <TT>operator=</TT> for <TT>SimpleCircle</TT>.
</DL>

<PRE><FONT COLOR="#0066FF">SimpleCircle&amp; SimpleCircle::operator=(const SimpleCircle &amp; rhs)
{
     if (this == &amp;rhs)
          return *this;
     delete itsRadius;
    itsRadius = new int;
    *itsRadius = rhs.GetRadius();
    return *this;
}
</FONT></PRE>

<DL>
	<DD><B>8.</B> Write a program that creates two <TT>SimpleCircle</TT> objects. Use
	the default constructor on one and instantiate the other with the value <TT>9</TT>.
	Call <TT>increment</TT> on each and then print their values. Finally, assign the
	second to the first and print its values.
</DL>

<PRE><FONT COLOR="#0066FF">#include &lt;iostream.h&gt;

class SimpleCircle
{
public:
      // constructors
     SimpleCircle();
     SimpleCircle(int);
     SimpleCircle(const SimpleCircle &amp;);
     ~SimpleCircle() {}

// accessor functions
     void SetRadius(int);
     int GetRadius()const;

// operators
     const SimpleCircle&amp; operator++();
     const SimpleCircle operator++(int);
     SimpleCircle&amp; operator=(const SimpleCircle &amp;);

private:
     int *itsRadius;
};


SimpleCircle::SimpleCircle()
{itsRadius = new int(5);}

SimpleCircle::SimpleCircle(int radius)
{itsRadius = new int(radius);}

SimpleCircle::SimpleCircle(const SimpleCircle &amp; rhs)
{
     int val = rhs.GetRadius();
     itsRadius = new int(val);
}
SimpleCircle&amp; SimpleCircle::operator=(const SimpleCircle &amp; rhs)
{
     if (this == &amp;rhs)
          return *this;
     *itsRadius = rhs.GetRadius();
     return *this;
}

const SimpleCircle&amp; SimpleCircle::operator++()
{
     ++(itsRadius);
     return *this;
}

// Operator ++(int) postfix. 
// Fetch then increment
const SimpleCircle SimpleCircle::operator++ (int)
{
// declare local SimpleCircle and initialize to value of *this
    SimpleCircle temp(*this);  
    ++(itsRadius);
    return temp;  
}
int SimpleCircle::GetRadius() const
{
     return *itsRadius;
}
int main()
{
     SimpleCircle CircleOne, CircleTwo(9);
     CircleOne++;
     ++CircleTwo;
     cout &lt;&lt; &quot;CircleOne: &quot; &lt;&lt; CircleOne.GetRadius() &lt;&lt; endl;
     cout &lt;&lt; &quot;CircleTwo: &quot; &lt;&lt; CircleTwo.GetRadius() &lt;&lt; endl;
     CircleOne = CircleTwo;
     cout &lt;&lt; &quot;CircleOne: &quot; &lt;&lt; CircleOne.GetRadius() &lt;&lt; endl;
     cout &lt;&lt; &quot;CircleTwo: &quot; &lt;&lt; CircleTwo.GetRadius() &lt;&lt; endl;
return 0;
}
</FONT></PRE>

<DL>
	<DD><B>9.</B> BUG BUSTERS: What is wrong with this implementation of the assignment
	operator?
</DL>

<PRE><FONT COLOR="#0066FF">SQUARE SQUARE ::operator=(const SQUARE &amp; rhs)
{
      itsSide = new int;
      *itsSide = rhs.GetSide();
      return *this;
}
</FONT></PRE>

<DL>
	<DD>You must check to see whether <TT>rhs</TT> equals <TT>this</TT>, or the call
	to <TT>a = a</TT> will crash your program.<BR>
	<BR>
	<B>10.</B> BUG BUSTERS: What is wrong with this implementation of <TT>operator+</TT>?
</DL>

<PRE><FONT COLOR="#0066FF">VeryShort  VeryShort::operator+ (const VeryShort&amp; rhs)
{
   itsVal += rhs.GetItsVal();
   return *this;
}
</FONT></PRE>

<DL>
	<DD>This <TT>operator+</TT> is changing the value in one of the operands, rather
	than creating a new <TT>VeryShort</TT> object with the sum. The right way to do this
	is as follows:
</DL>

<PRE><FONT COLOR="#0066FF">VeryShort  VeryShort::operator+ (const VeryShort&amp; rhs)
{
   return VeryShort(itsVal + rhs.GetItsVal());
}
</FONT></PRE>
<H3 ALIGN="CENTER"><FONT COLOR="#0066FF"></FONT></H3>
<H3><A NAME="Heading33"></A><FONT COLOR="#000077">Day 11</FONT></H3>
<H4 ALIGN="CENTER"><A NAME="Heading34"></A><FONT COLOR="#000077">Quiz</FONT></H4>

<DL>
	<DD><B>1. What are the first and last elements in <TT>SomeArray[25]</TT>?<BR>
	</B><TT><BR>
	SomeArray[0]</TT>,<TT> SomeArray[24]</TT><BR>
	<BR>
	<B>2. How do you declare a multidimensional array?<BR>
	</B><BR>
	Write a set of subscripts for each dimension. For example, <TT>SomeArray[2][3][2]</TT>
	is a three-dimensional array. The first dimension has two elements, the second has
	three, and <BR>
	the third has two.<BR>
	<BR>
	<B>3. Initialize the members of the array in Question 2.</B>
</DL>

<PRE><FONT COLOR="#0066FF">SomeArray[2][3][2] = { { {1,2},{3,4},{5,6} } , { {7,8},{9,10},{11,12} } };
</FONT></PRE>

<DL>
	<DD><B>4. How many elements are in the array <TT>SomeArray[10][5][20]</TT>?<BR>
	</B><BR>
	10x5x20=1,000<BR>
	<BR>
	<B>5. What is the maximum number of elements that you can add to a linked list?<BR>
	</B><BR>
	There is no fixed maximum. It depends on how much memory you have available.<BR>
	<BR>
	<B>6. Can you use subscript notation on a linked list?<BR>
	</B><BR>
	You can use subscript notation on a linked list only by writing your own class to
	contain the linked list and overloading the subscript operator.<BR>
	<BR>
	<B>7. What is the last character in the string &quot;Brad is a nice guy&quot;?<BR>
	</B><BR>
	The null character.
</DL>

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

<DL>
	<DD><B>1. </B>Declare a two-dimensional array that represents a tic-tac-toe game
	board.
</DL>

<PRE><FONT COLOR="#0066FF">int GameBoard[3][3];
</FONT></PRE>

<DL>
	<DD><B>2.</B> Write the code that initializes all the elements in the array you created
	in Exercise 1 to the value <TT>0</TT>.
</DL>

<PRE><FONT COLOR="#0066FF">int GameBoard[3][3] = { {0,0,0},{0,0,0},{0,0,0} }
</FONT></PRE>

<DL>
	<DD><B>3.</B> Write the declaration for a <TT>Node</TT> class that holds <TT>unsigned</TT>
	<TT>short</TT> integers.
</DL>

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
av高清久久久| 91精品国产综合久久精品麻豆| 麻豆91精品视频| 亚洲午夜久久久久中文字幕久| 亚洲黄色免费电影| 亚洲人成精品久久久久久| 亚洲日本丝袜连裤袜办公室| 中文字幕一区不卡| 亚洲欧美区自拍先锋| 亚洲人精品午夜| 亚洲男人电影天堂| 亚洲一区在线视频观看| 亚洲网友自拍偷拍| 日韩中文字幕亚洲一区二区va在线 | 九九**精品视频免费播放| 日韩电影在线一区| 麻豆成人av在线| 极品少妇一区二区三区精品视频 | 日本成人在线电影网| 久88久久88久久久| 高清国产一区二区三区| www.av精品| 欧美三区在线观看| 欧美一级xxx| 国产视频亚洲色图| 亚洲天堂av一区| 亚洲高清免费观看高清完整版在线观看| 一卡二卡欧美日韩| 午夜精品福利一区二区蜜股av| 免费国产亚洲视频| 丁香婷婷综合色啪| 日本精品一级二级| 欧美一区二区三区喷汁尤物| 欧美精品一区二区三区在线| 国产精品美女久久久久久| 亚洲一区二区三区中文字幕 | 欧美精品v国产精品v日韩精品| 欧美一级高清片| 欧美国产在线观看| 亚洲不卡一区二区三区| 国内偷窥港台综合视频在线播放| 成人动漫中文字幕| 91精品中文字幕一区二区三区| 亚洲精品一区二区三区福利| 亚洲人成网站精品片在线观看| 日韩国产一区二| 成人午夜在线免费| 欧美日本乱大交xxxxx| 久久精品人人做人人综合 | 亚洲欧美日本在线| 蜜臀av一区二区在线免费观看| gogogo免费视频观看亚洲一| 中文字幕免费不卡| 亚洲mv在线观看| 国产激情视频一区二区三区欧美| 91丨九色porny丨蝌蚪| 欧美电影免费观看高清完整版在| 中文字幕综合网| 日韩电影一区二区三区四区| 成人国产精品免费观看视频| 日韩一区二区免费电影| 亚洲丝袜美腿综合| 国内久久婷婷综合| 欧美午夜理伦三级在线观看| 久久久亚洲午夜电影| 亚洲h精品动漫在线观看| 成人免费电影视频| 日韩三级av在线播放| 伊人夜夜躁av伊人久久| 国产成人福利片| 欧美日韩免费一区二区三区 | 亚洲成人免费视频| 成人黄色国产精品网站大全在线免费观看 | 色狠狠综合天天综合综合| 欧美精品一区二区三区蜜桃视频 | 在线亚洲人成电影网站色www| 国产日韩在线不卡| 理论电影国产精品| 911精品国产一区二区在线| 亚洲天堂av一区| 成人自拍视频在线观看| 日韩美女一区二区三区四区| 午夜欧美视频在线观看 | 国产精品盗摄一区二区三区| 国产精一区二区三区| 欧美一级高清片| 婷婷久久综合九色综合绿巨人| 色综合久久中文字幕| 国产精品你懂的在线欣赏| 韩国av一区二区三区四区 | 日韩在线a电影| 欧美日韩精品三区| 亚洲小说欧美激情另类| 日本精品裸体写真集在线观看| 国产亚洲美州欧州综合国| 激情六月婷婷久久| 欧美电影免费观看高清完整版在线 | 不卡视频一二三四| 欧美国产成人在线| 国产伦精一区二区三区| 日韩精品一区二区三区四区| 人人爽香蕉精品| 国产一区二区三区免费播放| 色噜噜狠狠色综合欧洲selulu| 国产精品沙发午睡系列990531| 国产乱色国产精品免费视频| 精品美女在线观看| 精品一区二区国语对白| 26uuu国产一区二区三区| 国产一区在线精品| 久久综合九色综合久久久精品综合 | 亚洲午夜电影在线观看| 欧美欧美欧美欧美首页| 无码av中文一区二区三区桃花岛| 欧美日本乱大交xxxxx| 日本三级亚洲精品| 日韩视频在线你懂得| 激情小说亚洲一区| 国产精品毛片无遮挡高清| av成人免费在线观看| 亚洲欧美日韩中文字幕一区二区三区 | 人禽交欧美网站| 精品剧情v国产在线观看在线| 黄色成人免费在线| 国产视频一区在线观看| av高清久久久| 亚洲成人7777| 欧美变态tickle挠乳网站| 国产精品资源在线看| 国产精品日韩成人| 欧美在线观看你懂的| 日韩成人免费看| 久久免费看少妇高潮| 91美女片黄在线| 天堂精品中文字幕在线| 欧美精品一区二区三区很污很色的| 成人黄色免费短视频| 亚洲国产精品麻豆| 日韩欧美电影一区| 成人动漫一区二区三区| 亚洲国产日韩一区二区| 欧美成va人片在线观看| 成人国产一区二区三区精品| 亚洲午夜激情网站| 久久久噜噜噜久久人人看| 色婷婷av一区二区三区之一色屋| 日韩国产欧美一区二区三区| 国产亚洲欧美在线| 欧美午夜寂寞影院| 国产一区二区三区免费播放| 一区二区日韩av| 337p日本欧洲亚洲大胆精品| 色综合天天综合狠狠| 久久99在线观看| 一二三区精品视频| 久久综合视频网| 欧美午夜精品电影| 国产成人亚洲综合a∨猫咪| 亚洲高清免费观看高清完整版在线观看 | 欧美电影免费观看高清完整版在线| 99精品欧美一区二区三区小说| 青青草国产成人av片免费| 国产精品三级久久久久三级| 欧美一区二区在线免费观看| 9i在线看片成人免费| 精品一区二区三区免费观看 | 波多野结衣在线aⅴ中文字幕不卡| 午夜久久久久久久久久一区二区| 国产日韩精品久久久| 91精品国产综合久久香蕉麻豆 | 精品女同一区二区| 欧美色图免费看| 91一区在线观看| 成人在线视频一区二区| 日本女优在线视频一区二区| 一区二区免费在线| 国产精品伦理在线| 久久久久成人黄色影片| 欧美精品第1页| 欧美日韩在线播| 色综合av在线| eeuss影院一区二区三区| 激情综合色播激情啊| 91精品国产欧美一区二区成人| 91精品久久久久久久91蜜桃| 一区二区三区中文字幕精品精品| 97精品国产97久久久久久久久久久久| 天天综合色天天| 中文字幕永久在线不卡| 欧美一级生活片| www.欧美.com| 国产91精品一区二区麻豆亚洲| 亚洲成人av电影| 亚洲欧美欧美一区二区三区| 国产精品网友自拍| 久久久综合激的五月天| 欧美日本韩国一区二区三区视频| 盗摄精品av一区二区三区| 久久av老司机精品网站导航| 一区二区三区四区激情 |