为什么要在定义抽象类时使用abstract关键字
本文为原创,如需转载,请注明作者和出处,谢谢!<div class="post"><link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CADMINI%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C02%5Cclip_filelist.xml"><!--><xml>Normal07.8 磅02falsefalsefalseMicrosoftInternetExplorer4</xml><!--><!--><!--><style><!--/* Font Definitions */&#64;font-face{font-family:宋体;panose-1:2 1 6 0 3 1 1 1 1 1;}&#64;font-face{font-family:""&#64;宋体";panose-1:2 1 6 0 3 1 1 1 1 1;}/* Style Definitions */p.MsoNormal, li.MsoNormal, div.MsoNormal{mso-style-parent:"";margin:0cm;margin-bottom:.0001pt;text-align:justify;text-justify:inter-ideograph;font-size:10.5pt;font-family:"Times New Roman";}/* Page Definitions */&#64;page{}&#64;page Section1{size:595.3pt 841.9pt;margin:72.0pt 90.0pt 72.0pt 90.0pt;layout-grid:15.6pt;}div.Section1{page:Section1;}--></style><!--><style>/* Style Definitions */table.MsoNormalTable{mso-style-parent:"";font-size:10.0pt;font-family:"Times New Roman";}</style><!--> 众所周之,在任何面向对象的语言中(包括Java、C#),在定义抽象类时必须使用abstract关键字。虽然这已经习已为常了,但实际上abstract是为了在实现接口或继承抽象类避免歧议而必须存在的。
看如下代码:
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->abstractclassClass1
{
abstractvoidmethod();
}
页:
[1]