⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ectorsc.htm

📁 一个非常适合初学者入门的有关c++的文档
💻 HTM
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN" "http://www.w3.org/TR/REC-html40/frameset.dtd">
<HTML LANG="EN">
<HEAD>
<title>Effective C++, 2E | Constructors, Destructors, and Assignment Operators</TITLE>
<LINK REL=STYLESHEET HREF=../INTRO/ECMEC.CSS>




<SCRIPT LANGUAGE="Javascript" SRC="../JAVA/COOKIE.JS"></SCRIPT>
<SCRIPT LANGUAGE="Javascript">var imagemax = 0; setCurrentMax(0);</SCRIPT>
<SCRIPT LANGUAGE="Javascript" SRC="../JAVA/DINGBATS.JS"></SCRIPT>
<SCRIPT>
var dingbase = "ECTORDIR.HTM";
var dingtext = "EC++ Ctors/Dtors/op=, P";
if (self == top) {
 top.location.replace(dingbase + this.location.hash);
}
</SCRIPT>





</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" ONLOAD="setResize()">

<!-- SectionName="Ec++ Chapter Intro: Ctors, Dtors, and Operator=" -->
<DIV ALIGN="CENTER"><FONT SIZE="-1">Back to <A HREF="./EI10_FR.HTM" TARGET="_top">Item 10: Write operator delete if you write operator new.</A> &nbsp;&nbsp;<BR>&nbsp;&nbsp;Continue to <A HREF="./EI11_FR.HTM" TARGET="_top">Item 11: Declare a copy constructor and an assignment operator for classes with dynamically allocated memory.</A></FONT></DIV>

<P><A NAME="dingp1"></A><A NAME="p49"></A><FONT ID="egtitle">Constructors, Destructors, and Assignment Operators</FONT><SCRIPT>create_link(1);</SCRIPT>
</P>
<A NAME="2040"></A>
<A NAME="2041"></A>
Almost every class you write will have one or more constructors, a destructor, and an assignment operator. Little wonder. These are your bread-and-butter functions, the ones that control the fundamental operations of bringing a new object into existence and making sure it's initialized; getting rid of an object and making sure it's been properly cleaned up; and giving an object a new value. Making mistakes in these functions will lead to far-reaching and distinctly unpleasant repercussions throughout your classes, so it's vital that you get them right. In this section, I offer guidance on putting together the functions that comprise the backbone of well-formed <NOBR>classes.
<SCRIPT>create_link(2);</SCRIPT>
</NOBR></P>

<DIV ALIGN="CENTER"><FONT SIZE="-1">Back to <A HREF="./EI10_FR.HTM" TARGET="_top">Item 10: Write operator delete if you write operator new.</A> &nbsp;&nbsp;<BR>&nbsp;&nbsp;Continue to <A HREF="./EI11_FR.HTM" TARGET="_top">Item 11: Declare a copy constructor and an assignment operator for classes with dynamically allocated memory.</A></FONT></DIV>

</BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -