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

📄 yolinux c - c++ and dynamic memory allocation.mht

📁 linux下c++编程的好文章
💻 MHT
📖 第 1 页 / 共 5 页
字号:
public:
   Derived(){};
   ~Derived(){ cout << "Derived class destructor called" << =
endl; }
};


main()
{
   Base *ptr =3D new Derived();
   delete ptr;
}
    </PRE></TD></TR></TBODY></TABLE>Resutls:=20
        <P>Derived class destructor called <BR>Base class destructor =
called=20
        </P></DD></DL>
      <P>Note:=20
      <UL>
        <LI>If the delete operator is applied to the base class and the=20
        destructor is NOT virtual, then this will cause a memory leak as =
only a=20
        portion of the memory is freed.=20
        <LI>Base class destructor is not pure virtual (set =3D0) or =
there would be=20
        no base class implementation of the destructor..=20
        <LI>Class contructors can NOT be virtual. </LI></UL>
      <P><A name=3DBOOKS></A>
      <P>
      <HR>

      <TABLE cellSpacing=3D0 cellPadding=3D2 width=3D"100%" border=3D0>
        <TBODY>
        <TR bgColor=3D#ffcc33>
          <TD vAlign=3Dtop><IMG=20
            =
src=3D"http://www.yolinux.com/TUTORIALS/images/book40.gif"><B><BIG>Books:=
</BIG></B></TD></TR></TBODY></TABLE>
      <P>
      <DL>
        <DD>
        <TABLE border=3D1 celpadding=3D"5">
          <TBODY>
          <TR>
            <TD><IMG=20
              =
src=3D"http://www.yolinux.com/BOOKS/0131857576.01.MZZZZZZZ.jpg"></TD>
            <TD vAlign=3Dtop>C++ How to Program <BR>by Harvey M. Deitel, =
Paul J.=20
              Deitel <BR>ISBN #0131857576, Prentice Hall=20
              <P>Fifth edition. The first edition of this book (and =
Proffessor=20
              Sheely at UTA) taught me to program C++. It is complete =
and covers=20
              all the nuances of the C++ language. It also has good code =

              examples. Good for both learning and reference. </P>
            <TD vAlign=3Dtop><A=20
              =
href=3D"http://www.amazon.com/exec/obidos/ASIN/0131857576/yolinux-20"><IM=
G=20
              alt=3DAmazon.com=20
              =
src=3D"http://www.yolinux.com/TUTORIALS/images/Amazon-BuyABook88x31.gif">=
</A>=20
              <BR><IMG height=3D1=20
              =
src=3D"http://service.bfast.com/bfast/serve?bfmid=3D2181&amp;sourceid=3D3=
9358384&amp;bfpid=3D0131857576&amp;bfmtype=3Dbook"=20
              width=3D1 border=3D0 NOSAVE><A=20
              =
href=3D"http://service.bfast.com/bfast/click?bfmid=3D2181&amp;sourceid=3D=
39358384&amp;bfpid=3D0131857576&amp;bfmtype=3Dbook"=20
              target=3D_top><IMG height=3D60=20
              =
src=3D"http://www.yolinux.com/TUTORIALS/images/BarnesNobles.gif"=20
              width=3D75></A> </TD></TR>
          <TR>
            <TD><IMG=20
              =
src=3D"http://www.yolinux.com/BOOKS/0201615622.01.MZZZZZZZ.jpg"></TD>
            <TD vAlign=3Dtop>Exceptional C++: 47 Engineering Puzzles,=20
              Programming Problems and Solutions <BR>by Herb Sutter =
<BR>ISBN=20
              #0201615622, Addison-Wesley Professional=20
              <P>Advanced C++ features and STL.=20
              <P></P>
            <TD vAlign=3Dtop><A=20
              =
href=3D"http://www.amazon.com/exec/obidos/ASIN/0201615622/yolinux-20"><IM=
G=20
              alt=3DAmazon.com=20
              =
src=3D"http://www.yolinux.com/TUTORIALS/images/Amazon-BuyABook88x31.gif">=
</A>=20
              <BR><IMG height=3D1=20
              =
src=3D"http://service.bfast.com/bfast/serve?bfmid=3D2181&amp;sourceid=3D3=
9358384&amp;bfpid=3D0201615622&amp;bfmtype=3Dbook"=20
              width=3D1 border=3D0 NOSAVE><A=20
              =
href=3D"http://service.bfast.com/bfast/click?bfmid=3D2181&amp;sourceid=3D=
39358384&amp;bfpid=3D0201615622&amp;bfmtype=3Dbook"=20
              target=3D_top><IMG height=3D60=20
              =
src=3D"http://www.yolinux.com/TUTORIALS/images/BarnesNobles.gif"=20
              width=3D75></A> </TD></TR>
          <TR>
            <TD><IMG=20
              =
src=3D"http://www.yolinux.com/BOOKS/020170434X.01.MZZZZZZZ.jpg"></TD>
            <TD vAlign=3Dtop>More Exceptional C++ <BR>by Herb Sutter =
<BR>ISBN=20
              #020170434X, Addison-Wesley Professional=20
              <P></P>
            <TD vAlign=3Dtop><A=20
              =
href=3D"http://www.amazon.com/exec/obidos/ASIN/020170434X/yolinux-20"><IM=
G=20
              alt=3DAmazon.com=20
              =
src=3D"http://www.yolinux.com/TUTORIALS/images/Amazon-BuyABook88x31.gif">=
</A>=20
              <BR><IMG height=3D1=20
              =
src=3D"http://service.bfast.com/bfast/serve?bfmid=3D2181&amp;sourceid=3D3=
9358384&amp;bfpid=3D020170434X&amp;bfmtype=3Dbook"=20
              width=3D1 border=3D0 NOSAVE><A=20
              =
href=3D"http://service.bfast.com/bfast/click?bfmid=3D2181&amp;sourceid=3D=
39358384&amp;bfpid=3D020170434X&amp;bfmtype=3Dbook"=20
              target=3D_top><IMG height=3D60=20
              =
src=3D"http://www.yolinux.com/TUTORIALS/images/BarnesNobles.gif"=20
              width=3D75></A> </TD></TR>
          <TR>
            <TD><IMG=20
              =
src=3D"http://www.yolinux.com/BOOKS/0201924889.01.MZZZZZZZ.jpg"></TD>
            <TD vAlign=3Dtop>Effective C++: 50 Specific Ways to Improve =
Your=20
              Programs and Design (2nd Edition) <BR>by Scott Meyers =
<BR>ISBN=20
              #0201924889, Addison-Wesley Professional=20
              <P></P>
            <TD vAlign=3Dtop><A=20
              =
href=3D"http://www.amazon.com/exec/obidos/ASIN/0201924889/yolinux-20"><IM=
G=20
              alt=3DAmazon.com=20
              =
src=3D"http://www.yolinux.com/TUTORIALS/images/Amazon-BuyABook88x31.gif">=
</A>=20
              <BR><IMG height=3D1=20
              =
src=3D"http://service.bfast.com/bfast/serve?bfmid=3D2181&amp;sourceid=3D3=
9358384&amp;bfpid=3D0201924889&amp;bfmtype=3Dbook"=20
              width=3D1 border=3D0 NOSAVE><A=20
              =
href=3D"http://service.bfast.com/bfast/click?bfmid=3D2181&amp;sourceid=3D=
39358384&amp;bfpid=3D0201924889&amp;bfmtype=3Dbook"=20
              target=3D_top><IMG height=3D60=20
              =
src=3D"http://www.yolinux.com/TUTORIALS/images/BarnesNobles.gif"=20
              width=3D75></A> </TD></TR>
          <TR>
            <TD><IMG=20
              =
src=3D"http://www.yolinux.com/BOOKS/020163371X.01.MZZZZZZZ.jpg"></TD>
            <TD vAlign=3Dtop>More Effective C++: 35 New Ways to improve =
your=20
              Programs and Designs <BR>by Scott Meyers <BR>ISBN =
#020163371X,=20
              Addison-Wesley Professional=20
              <P></P>
            <TD vAlign=3Dtop><A=20
              =
href=3D"http://www.amazon.com/exec/obidos/ASIN/020163371X/yolinux-20"><IM=
G=20
              alt=3DAmazon.com=20
              =
src=3D"http://www.yolinux.com/TUTORIALS/images/Amazon-BuyABook88x31.gif">=
</A>=20
              <BR><IMG height=3D1=20
              =
src=3D"http://service.bfast.com/bfast/serve?bfmid=3D2181&amp;sourceid=3D3=
9358384&amp;bfpid=3D020163371X&amp;bfmtype=3Dbook"=20
              width=3D1 border=3D0 NOSAVE><A=20
              =
href=3D"http://service.bfast.com/bfast/click?bfmid=3D2181&amp;sourceid=3D=
39358384&amp;bfpid=3D020163371X&amp;bfmtype=3Dbook"=20
              target=3D_top><IMG height=3D60=20
              =
src=3D"http://www.yolinux.com/TUTORIALS/images/BarnesNobles.gif"=20
              width=3D75></A> </TD></TR></TBODY></TABLE></DD></DL></TD>
    <TD vAlign=3Dtop width=3D160 bgColor=3D#c0c0c0>
      <CENTER><!-- BEGIN RICH-MEDIA BURST! CODE -->
      <SCRIPT language=3DJavaScript>=0A=
rnum=3DMath.round(Math.random() * 100000);=0A=
document.write('<scr'+'ipt =
src=3D"http://www.burstnet.com/cgi-bin/ads/sk9427a.cgi/v=3D2.0S/sz=3D120x=
600A|160x600A/'+rnum+'/RETURN-CODE/JS/"></scr'+'ipt>');=0A=
</SCRIPT>
      <NOSCRIPT><A=20
      =
href=3D"http://www.burstnet.com/ads/sk9427a-map.cgi/ns/v=3D2.0S/sz=3D120x=
600A|160x600A/"=20
      target=3D_top><IMG alt=3D"Click Here"=20
      =
src=3D"http://www.burstnet.com/cgi-bin/ads/sk9427a.cgi/ns/v=3D2.0S/sz=3D1=
20x600A|160x600A/"=20
      border=3D0></A>=20
</NOSCRIPT><!-- END BURST CODE --></CENTER></TD></TR></TBODY></TABLE>
<P>
<HR SIZE=3D5>

<P>
<TABLE>
  <TBODY>
  <TR>
    <TD vAlign=3Dtop width=3D"60%">Return to <A=20
      href=3D"http://yolinux.com/">http://yolinux.com/</A> <BR>Return to =
<A=20
      href=3D"http://www.yolinux.com/TUTORIALS/index.html">YoLinux =
Tutorial=20
      Index</A> <BR><A=20
      href=3D"http://www.yolinux.com/YoLinuxEmailForm.html">Feedback =
Form</A>=20
      <P><SMALL>Copyright =C2=A9 2006 by <I>Greg Ippolito</I></SMALL> =
</P></TD>
    <TD vAlign=3Dtop align=3Dright><!-- BEGIN RICH-MEDIA BURST! CODE -->
      <SCRIPT language=3DJavaScript>=0A=
rnum=3DMath.round(Math.random() * 100000);=0A=
document.write('<scr'+'ipt =
src=3D"http://www.burstnet.com/cgi-bin/ads/ba9427a.cgi/v=3D2.0S/sz=3D468x=
60B/'+rnum+'/RETURN-CODE/JS/"></scr'+'ipt>');=0A=
</SCRIPT>
      <NOSCRIPT><A=20
      =
href=3D"http://www.burstnet.com/ads/ba9427a-map.cgi/ns/v=3D2.0S/sz=3D468x=
60B/"=20
      target=3D_top><IMG alt=3D"Click Here"=20
      =
src=3D"http://www.burstnet.com/cgi-bin/ads/ba9427a.cgi/ns/v=3D2.0S/sz=3D4=
68x60B/"=20
      border=3D0></A> </NOSCRIPT><!-- END BURST CODE =
--></TD></TR></TBODY></TABLE>
<P></P></BODY></HTML>

------=_NextPart_000_016F_01C776A9.5742E1A0
Content-Type: image/png
Content-Transfer-Encoding: base64
Content-Location: http://www.yolinux.com/TUTORIALS/images/YoLinux_Tutorial_logo.png

iVBORw0KGgoAAAANSUhEUgAAALoAAADGCAYAAABl7ppLAAAABmJLR0QA/wD/AP+gvaeTAAAACXBI
WXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH1wMWBisEhK2xZgAAIABJREFUeNrsvXd8Xdd15/vdp95e
gIsOEiRYwC5WdcmyRDGSInksyZRb7NhJLMWePDvOS6J44mRSnBd5MvHEfrEz0oxLLE+ikth5saRY
Fm2rmKIKKZESKVaAFb3j9tP2++OcC0IwAIIUKdE21udzPyj34t6DfX577d/67bXWhjmbszmbszmb
szmbs58bE3ND8LZZGtgw4eddwPDcsMzZzwt47wWemvC4e4rXbQbkpMfWWUyGOZuzi8YmA/jeWQJ9
qtdtDZ4bAu4HWueG9/yY8nN87VuB9gAY952n92wNQPlOedXWCZ79bmDnFNdSee7eCY/0HJR/MW0q

⌨️ 快捷键说明

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