<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8">
<meta name="generator" content="pdf2htmlEX">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="stylesheet" href="https://static.pudn.com/base/css/base.min.css">
<link rel="stylesheet" href="https://static.pudn.com/base/css/fancy.min.css">
<link rel="stylesheet" href="https://static.pudn.com/prod/directory_preview_static/6275beb59221806f9d7fec9d/raw.css">
<script src="https://static.pudn.com/base/js/compatibility.min.js"></script>
<script src="https://static.pudn.com/base/js/pdf2htmlEX.min.js"></script>
<script>
try{
pdf2htmlEX.defaultViewer = new pdf2htmlEX.Viewer({});
}catch(e){}
</script>
<title></title>
</head>
<body>
<div id="sidebar" style="display: none">
<div id="outline">
</div>
</div>
<div id="pf1" class="pf w0 h0" data-page-no="1"><div class="pc pc1 w0 h0"><img class="bi x0 y0 w1 h1" alt="" src="https://static.pudn.com/prod/directory_preview_static/6275beb59221806f9d7fec9d/bg1.jpg"><div class="c x0 y1 w2 h2"><div class="t m0 x1 h3 y2 ff1 fs0 fc0 sc0 ls0 ws0">C++ Prog<span class="_ _0"></span>ramming</div><div class="t m0 x2 h4 y3 ff2 fs1 fc1 sc0 ls0 ws0">Chapter<span class="_ _0"></span> 5 Inherita<span class="_ _1"></span>nce<span class="_ _1"></span> and Polymophism</div></div></div><div class="pi" data-data='{"ctm":[1.333333,0.000000,0.000000,1.333333,0.000000,0.000000]}'></div></div>
</body>
</html>
<div id="pf2" class="pf w0 h0" data-page-no="2"><div class="pc pc2 w0 h0"><img class="bi x0 y0 w1 h1" alt="" src="https://static.pudn.com/prod/directory_preview_static/6275beb59221806f9d7fec9d/bg2.jpg"><div class="c x0 y1 w2 h2"><div class="t m0 x3 h5 y4 ff1 fs1 fc0 sc0 ls0 ws0">Index</div><div class="t m0 x3 h6 y5 ff3 fs2 fc2 sc0 ls0 ws0"></div><div class="t m0 x4 h7 y6 ff2 fs3 fc1 sc0 ls0 ws0">5.1 Introduction </div><div class="t m0 x3 h6 y7 ff3 fs2 fc2 sc0 ls0 ws0"></div><div class="t m0 x4 h7 y8 ff2 fs3 fc1 sc0 ls0 ws0">5.2 Base Class and Der<span class="_ _0"></span>ived Class</div><div class="t m0 x5 h8 y9 ff3 fs4 fc0 sc0 ls0 ws0"></div><div class="t m0 x6 h9 ya ff2 fs5 fc1 sc0 ls0 ws0">5.2.1 Access Control of Inheritance</div><div class="t m0 x5 h8 yb ff3 fs4 fc0 sc0 ls0 ws0"></div><div class="t m0 x6 h9 yc ff2 fs5 fc1 sc0 ls0 ws0">5.2.2 Overriding Methods</div><div class="t m0 x5 h8 yd ff3 fs4 fc0 sc0 ls0 ws0"></div><div class="t m0 x6 h9 ye ff2 fs5 fc1 sc0 ls0 ws0">5.2.3 Constructors under Inheritance</div><div class="t m0 x3 h6 yf ff3 fs2 fc2 sc0 ls0 ws0"></div><div class="t m0 x4 h7 y10 ff2 fs3 fc1 sc0 ls0 ws0">5.3 Polymorphism</div><div class="t m0 x5 h8 y11 ff3 fs4 fc0 sc0 ls0 ws0"></div><div class="t m0 x6 h9 y12 ff2 fs5 fc1 sc0 ls0 ws0">5.3.1 Polymorphism</div><div class="t m0 x5 h8 y13 ff3 fs4 fc0 sc0 ls0 ws0"></div><div class="t m0 x6 h9 y14 ff2 fs5 fc1 sc0 ls0 ws0">5.3.2 Virtual Functions</div><div class="t m0 x5 h8 y15 ff3 fs4 fc0 sc0 ls0 ws0"></div><div class="t m0 x6 h9 y16 ff2 fs5 fc1 sc0 ls0 ws0">5.3.3 Pure Virtual Functions and Abstract Class</div><div class="t m0 x3 h6 y17 ff3 fs2 fc2 sc0 ls0 ws0"></div><div class="t m0 x4 h7 y18 ff2 fs3 fc1 sc0 ls0 ws0">5.4 Multiple Inheritance </div><div class="t m0 x5 h8 y19 ff3 fs4 fc0 sc0 ls0 ws0"></div><div class="t m0 x6 h9 y1a ff2 fs5 fc1 sc0 ls0 ws0">5.4.1 Multiple Inheritance</div><div class="t m0 x5 h8 y1b ff3 fs4 fc0 sc0 ls0 ws0"></div><div class="t m0 x6 h9 y1c ff2 fs5 fc1 sc0 ls0 ws0">5.4.2 Virtual Inheritance</div></div></div><div class="pi" data-data='{"ctm":[1.333333,0.000000,0.000000,1.333333,0.000000,0.000000]}'></div></div>
<div id="pf3" class="pf w0 h0" data-page-no="3"><div class="pc pc3 w0 h0"><img class="bi x0 y0 w1 h1" alt="" src="https://static.pudn.com/prod/directory_preview_static/6275beb59221806f9d7fec9d/bg3.jpg"><div class="c x0 y1 w2 h2"><div class="t m0 x7 ha y2 ff4 fs0 fc0 sc1 ls0 ws0">Chap. 5 Inherence and polymophism<span class="_ _2"></span> </div><div class="t m0 x8 h4 y3 ff2 fs1 fc1 sc0 ls0 ws0">5.1 Intr<span class="_ _0"></span>oduction</div></div></div><div class="pi" data-data='{"ctm":[1.333333,0.000000,0.000000,1.333333,0.000000,0.000000]}'></div></div>
<div id="pf4" class="pf w0 h0" data-page-no="4"><div class="pc pc4 w0 h0"><img class="bi x0 y0 w1 h1" alt="" src="https://static.pudn.com/prod/directory_preview_static/6275beb59221806f9d7fec9d/bg4.jpg"><div class="c x0 y1 w2 h2"><div class="t m0 x3 h5 y4 ff1 fs1 fc0 sc0 ls0 ws0">5.1 Introduct<span class="_ _1"></span>ion</div><div class="t m0 x3 h6 y1d ff3 fs2 fc2 sc0 ls0 ws0"></div><div class="t m0 x4 h7 y1e ff2 fs3 fc1 sc0 ls0 ws0">Why to inherit?</div><div class="t m0 x5 hb y1f ff3 fs6 fc0 sc0 ls0 ws0"></div><div class="t m0 x6 hc y20 ff2 fs7 fc1 sc0 ls0 ws0">When a new p<span class="_ _1"></span>roblem appea<span class="_ _1"></span>rs, old program<span class="_ _1"></span>s can </div><div class="t m0 x6 hc y21 ff2 fs7 fc1 sc0 ls0 ws0">not solve a<span class="_ _1"></span>nd we must modify th<span class="_ _1"></span>em.</div><div class="t m0 x5 hb y22 ff3 fs6 fc0 sc0 ls0 ws0"></div><div class="t m0 x6 hc y23 ff2 fs7 fc1 sc0 ls0 ws0">Problem<span class="_ _1"></span>?</div><div class="t m0 x3 h6 y24 ff3 fs2 fc2 sc0 ls0 ws0"></div><div class="t m0 x4 h7 y25 ff2 fs3 fc2 sc0 ls0 ws0">Inheritance</div><div class="t m0 x5 hb y26 ff3 fs6 fc0 sc0 ls0 ws0"></div><div class="t m0 x6 hc y27 ff2 fs7 fc1 sc0 ls0 ws0">builds a new cla<span class="_ _1"></span>ss by <span class="fc3">de<span class="_ _1"></span>riving</span> fro<span class="_ _1"></span>m an already<span class="_ _1"></span> </div><div class="t m0 x6 hc y28 ff2 fs7 fc1 sc0 ls0 ws0">existing class</div><div class="t m0 x5 hb y29 ff3 fs6 fc0 sc0 ls0 ws0"></div><div class="t m0 x6 hc y2a ff2 fs7 fc1 sc0 ls0 ws0">promo<span class="_ _1"></span>tes <span class="fc2">code reuse</span> beca<span class="_ _1"></span>use the code in the base </div><div class="t m0 x6 hc y2b ff2 fs7 fc1 sc0 ls0 ws0">class is inherited by the subclass and thu<span class="_ _1"></span>s need not </div><div class="t m0 x6 hc y2c ff2 fs7 fc1 sc0 ls0 ws0">be rewritten</div></div></div><div class="pi" data-data='{"ctm":[1.333333,0.000000,0.000000,1.333333,0.000000,0.000000]}'></div></div>
<div id="pf5" class="pf w0 h0" data-page-no="5"><div class="pc pc5 w0 h0"><img class="bi x0 y0 w1 h1" alt="" src="https://static.pudn.com/prod/directory_preview_static/6275beb59221806f9d7fec9d/bg5.jpg"><div class="c x0 y1 w2 h2"><div class="t m0 x3 h5 y4 ff1 fs1 fc0 sc0 ls0 ws0">5.1 Introduct<span class="_ _1"></span>ion</div><div class="t m0 x9 h7 y2d ff2 fs3 fc1 sc0 ls0 ws0">monkey</div><div class="t m0 xa h7 y2e ff2 fs3 fc1 sc0 ls0 ws0">lion<span class="_ _3"> </span>tiger<span class="_ _4"> </span>leopard</div><div class="t m0 xb h7 y2d ff2 fs3 fc1 sc0 ls0 ws0">cat<span class="_ _5"> </span>bird</div><div class="t m0 xc h7 y2f ff2 fs3 fc1 sc0 ls0 ws0">animal</div></div></div><div class="pi" data-data='{"ctm":[1.333333,0.000000,0.000000,1.333333,0.000000,0.000000]}'></div></div>