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

📄 xt7.htm

📁 有关C++程序设计的复习资料
💻 HTM
📖 第 1 页 / 共 2 页
字号:
            href="http://www.nuist.edu.cn/JSJ/syjx/sbcl.htm"> 申报材料</A></DIV></TD></TR>
        <TR>
          <TD height=26>
            <DIV align=right><IMG height=15 src="xt7.files/article_common.gif" 
            width=9></DIV></TD>
          <TD>
            <DIV align=left><A class=mb14 
            href="http://www.nuist.edu.cn/JSJ/syjx/szll.htm"> 师资力量</A></DIV></TD></TR>
        <TR>
          <TD height=26>
            <DIV align=right><IMG height=15 src="xt7.files/article_common.gif" 
            width=9></DIV></TD>
          <TD>
            <DIV align=center>
            <P align=left><A class=mb14 
            href="http://www.nuist.edu.cn/JSJ/syjx/jxcg.htm"> 教学成果</A></P></DIV></TD></TR>
        <TR>
          <TD height=26>
            <DIV align=right><IMG height=15 src="xt7.files/article_common.gif" 
            width=9></DIV></TD>
          <TD>
            <DIV align=left><A 
            href="http://www.nuist.edu.cn/JSJ/syjx/jxkh.htm"> 教学考核</A></DIV></TD></TR>
        <TR>
          <TD height=26>
            <DIV align=right><IMG height=15 src="xt7.files/article_common.gif" 
            width=9></DIV></TD>
          <TD>
            <DIV align=left><A class=mb14 
            href="http://www.nuist.edu.cn/JSJ/syjx/zwpj.htm"> 自我评价</A></DIV></TD></TR>
        <TR>
          <TD height=26>
            <DIV align=right><IMG height=15 src="xt7.files/article_common.gif" 
            width=9></DIV></TD>
          <TD>
            <DIV align=left><A class=mb14 
            href="http://www.nuist.edu.cn/JSJ/syjx/jsgh.htm"> 建设规划</A></DIV></TD></TR>
        <TR>
          <TD height=26>
            <DIV align=right><IMG height=15 src="xt7.files/article_common.gif" 
            width=9></DIV></TD>
          <TD>
            <DIV align=left><A class=mb14 
            href="http://www.nuist.edu.cn/JSJ/syjx/jcxy.htm"> 教材选用</A></DIV></TD></TR>
        <TR>
          <TD height=2></TD>
          <TD></TD></TR></TBODY></TABLE></TD>
    <TD vAlign=top colSpan=2>
      <TABLE class=bg height=241 cellSpacing=0 cellPadding=0 width="100%" 
      border=0>
        <TBODY>
        <TR>
          <TD width="11%" height=33><IMG height=34 src="xt7.files/homedha.gif" 
            width=55><IMG height=34 src="xt7.files/homedhbg.gif" width=8></TD>
          <TD 
            width="89%"><!-- InstanceBeginEditable name="EditRegion4" --><SPAN 
            class=s14><STRONG>习题七</STRONG></SPAN><!-- InstanceEndEditable --></TD></TR>
        <TR>
          <TD colSpan=2><!-- InstanceBeginEditable name="EditRegion5" -->
            <TABLE cellSpacing=1 cellPadding=1 width="100%" border=1>
              <TBODY>
              <TR>
                <TD>
                  <DIV align=center>第7章 多态性</DIV></TD></TR>
              <TR>
                <TD class=xt12>
                  <P><SPAN class=xt12>7.1 对定义重载函数的下列要求中,_是错误的<BR>A. 要求参数的个数相同 B. 
                  要求参数中至少有一个类型不同<BR>C. 要求参数个数相同时,参数类型不同 D. 
                  要求函数的返回值不同<BR>答:D</SPAN></P>
                  <P>7.2 系统在调用重载函数时,往往根据一些条件确定哪个重载函数被调用,在下列选项中不能作为依据的是 。<BR>A. 
                  参数个数 B. 参数的类型<BR>C. 函数的名称 D. 函数的类型<BR>答:D</P>
                  <P>7.3 下列对重载函数的描述中, 是错误的。<BR>A. 重载函数中不允许使用默认参数 B. 
                  重载函数中编译是根据参数表进行选择的<BR>C. 不要使用重载函数来描述毫无相干的函数 D. 
                  构造函数重载会给初始化带来多种形式<BR>答:A</P>
                  <P>7.4 运算符重载函数是 。<BR>A. 成员函数 B. 友元函数<BR>C. 内联函数 D. 
                  带默认参数的函数<BR>答:C</P>
                  <P>7.5 关于虚函数的描述中, 是正确的。<BR>A. 虚函数是一个static类型的成员函数 B. 
                  虚函数是一个非成员函数<BR>C. 基类中说明了虚函数后,派生类中与其对应的函数可以不必说明为虚函数<BR>D. 
                  派生类的许函数与其基类中虚函数具有不同的参数个数和类型<BR>答:C</P>
                  <P>7.6 阅读下面程序,写出程序的运行结果<BR>#include 
                  &lt;iostream.h&gt;<BR>class point<BR>{<BR> int 
                  x,y;<BR> public:<BR> point(int vx,int 
                  vy){x=vx;y=vy;}<BR> point(){x=0;y=0;}<BR> point 
                  operator+(point p1)<BR> {<BR>  point p;<BR>  int 
                  px=x+p1.x;<BR>  int py=y+p1.y;<BR>  return 
                  point(px,py);<BR> }<BR> point operator-(point 
                  p1)<BR> {<BR>  point p;<BR>  int px=x-p1.x;<BR>  int 
                  py=y-p1.y;<BR>  return point(px,py);<BR> }<BR> void 
                  print()<BR> {<BR>  cout&lt;&lt;x&lt;&lt;”,”&lt;&lt;y&lt;&lt;endl;<BR> }<BR>};<BR>void 
                  main()<BR>{<BR> point 
                  p1(10,10),p2(20,20);<BR> p1=p1+p2;<BR> p1.print();<BR>}<BR>答:30,30</P>
                  <P>7.7阅读下面程序,写出程序的运行结果<BR>#include 
                  &lt;iostream.h&gt;<BR>static int 
                  dys[]={31,28,31,30,31,30,31,31,30,31,30,31};<BR>class 
                  date<BR>{<BR> int mo,da,yr;<BR> public:<BR> date(int m,int d, 
                  int y){mo=m;da=d;yr=y;}<BR> date(){};<BR> void 
                  disp()<BR> {<BR>  cout&lt;&lt;mo&lt;&lt;”/”&lt;&lt;da&lt;&lt;”/”&lt;&lt;yr&lt;&lt;endl;<BR> }<BR> friend 
                  date operator+(date&amp;d,int day)<BR> {<BR>  date 
                  dt;<BR>  dt.mo=d.mo;<BR>  dt.yr=d.yr;<BR>  day+=d.da;<BR>  while 
                  (day&gt;dys[dt.mo-1])<BR>  {<BR>   day-=day[dt.mo-1];<BR>   if(++dt.mo==13)<BR>   {<BR>    dt.mo=1;<BR>    dt.yr++;<BR>   }<BR>  }<BR>  dt.data=day;<BR>  return 
                  dt;<BR> }<BR>};<BR>void main()<BR>{<BR> date 
                  d1(2,10,2001),d2;<BR> d2=d1+465;<BR> d2.disp();<BR>}<BR>答:5/21/2002</P>
                  <P>7.8 以下程序的执行结果是 。<BR>#include &lt;iostream.h&gt;<BR>class 
                  Sample<BR>{<BR> private:<BR> int 
                  x;<BR> public:<BR> Sample(){x=0;}<BR> void 
                  disp()<BR> {<BR>  cout&gt;&gt;”x=”&lt;&lt;x&lt;&lt;endl;<BR> }<BR> void 
                  operator++(){x+=10;}<BR>};<BR>void main()<BR>{<BR> Sample 
                  obj;<BR> obj.disp();<BR> obj++;<BR> cout&lt;&lt;”执行obj以后”&lt;&lt;endl;<BR> obj.disp();<BR>}<BR>答:x=0<BR>执行obj以后<BR>x=10</P>
                  <P>7.9 编写一个程序计算三角形、正方形和圆形三种图形的面积。<BR>#include 
                  &lt;iostream.h&gt;<BR>class base<BR>{<BR> protected:<BR> int 
                  x,y;<BR> public:<BR> base(int x,int 
                  y)<BR> {base::x=x;base::y=y;}<BR>  virtual void 
                  disp()<BR>  {cout&lt;&lt;” 
                  这个类没有面积”&lt;&lt;endl;}<BR> };<BR>class triangle:public 
                  base<BR>{<BR> public:<BR> triangle(int x,int 
                  y):base(x,y){};<BR> void 
                  disp()<BR> {<BR>  cout&lt;&lt;”三角形面积:”&lt;&lt;x*y*0.5&lt;&lt;endl;<BR> }<BR>};<BR>class 
                  square:public base<BR>{<BR> public:<BR> square(int 
                  x):base(x,x){};<BR> void 
                  disp()<BR> {<BR>  cout&lt;&lt;”正方形面积:”&lt;&lt;x*x&lt;&lt;endl;<BR> }<BR>};<BR>class 
                  circle::public base<BR>{<BR> public:<BR> circle(int 
                  x):base(x,x){};<BR> void 
                  disp()<BR> {<BR>  cout&lt;&lt;”圆形面积:”&lt;&lt;x*x*3.1416&lt;&lt;endl;<BR> }<BR>};<BR>void 
                  main()<BR>{<BR> base *p;<BR> triangle t(20,20);<BR> square 
                  s(20);<BR> circle 
                  c(20);<BR> p=&amp;t;<BR> p-&gt;disp();<BR> p=&amp;s;<BR> p-&gt;disp();<BR> p=&amp;c;<BR> p-&gt;disp();<BR>}<BR>7.10定义一个计数器类Counter,对其重载运算符“+”。<BR>#include 
                  &lt;iostream.h&gt;<BR>class Counter<BR>{<BR> int 
                  n;<BR> public:<BR> Counter(){n=0;}<BR> Counter(int 
                  i){n=i;}<BR> Counter operator+(Counter c)<BR> {<BR>  Counter 
                  temp;<BR>  temp.n=n+c.n;<BR>  return temp;<BR> }<BR> void 
                  disp()<BR> {<BR>  cout&lt;&lt;”n=”&lt;&lt;n&lt;&lt;endl;<BR> }<BR>};<BR>void 
                  main()<BR>{<BR> Counter 
                  c1(5),c2(10),c3;<BR> c3=c1+c2;<BR> c1.disp();<BR> c2.disp();<BR> c3.disp();<BR>}</P>
                  <P>7.11 
                  编写一个程序实现图书和杂志销售管理。当输入一系列图书和杂志销售记录后,将销售良好(图书每月销售500以上,杂志每月2500以上)的图书和杂志名称显示出来。<BR>#include 
                  &lt;iostream.h&gt;<BR>#inlcude &lt;stdio.h&gt;<BR>enum Boolean 
                  {False, True};<BR>class base<BR>{<BR> protected:<BR> char 
                  title[80];<BR> public:<BR> void 
                  gettitle()<BR> {<BR>  cout&lt;&lt;”书名:”; 
                  cin&gt;&gt;title;<BR> }<BR> void 
                  printtitle()<BR> {<BR>  cout&lt;&lt;”书名:”&lt;&lt;title&lt;&lt;”:”;<BR> }<BR> virtual 
                  Boolean isgood()=0;<BR>};<BR>class Book:public 
                  base<BR>{<BR> int numsold;<BR> public:<BR> void 
                  getsold()<BR> {<BR>  cout&lt;&lt;”每月销售书量:”; 
                  cin&gt;&gt;numsold;<BR> }<BR> Boolean 
                  isgood()<BR> {<BR>  return(numsold&gt;500)?True:False;<BR> }<BR>};<BR>class 
                  Journal:public base<BR>{<BR> int numsold;<BR> public:<BR> void 
                  getsold()<BR> {<BR>  cout&lt;&lt;”每月销售杂志书量:”; 
                  cin&gt;&gt;numsold;<BR> }<BR> Boolean 
                  isgood()<BR> {<BR>  return(numsold&gt;2500)?True:False;<BR> }<BR>};<BR>void 
                  main()<BR>{<BR> base *p[50];<BR> Book *pbook;<BR> Jouranl 
                  *pjour;<BR> char ch;<BR> int 
                  count=0;<BR> do<BR> {<BR>  cout&lt;&lt;”输入书(b)或杂志(j):”;<BR>  cin&gt;&gt;ch;<BR>  if(ch==’b’)<BR>  {<BR>   pbook=new 
                  Book;<BR>   pbook-&gt;gettitle();<BR>   pbook-&gt;getsold();<BR>   p[count++]=pbook;<BR>  }<BR>  else 
                  if(ch==’j’)<BR>  {<BR>   pjour=new 
                  Journal;<BR>   pjour-&gt;gettitle();<BR>   pjour-&gt;getsold();<BR>   p[count++]=pjour;<BR>  }<BR>  else<BR>   cout&lt;&lt;”输入错误”&lt;&lt;endl;<BR>   cout&lt;&lt;”输入另外一项吗(y/n)?”<BR>   cin&gt;ch;<BR> }while(ch==’y’);<BR> for(int 
                  i=0;i&lt;count;i++)<BR> {<BR>  if(p[i]-isgood()==True)<BR>  {<BR>   p[i]-&gt;printtitle();<BR>   cout&lt;&lt;”销售良好”&lt;&lt;endl;<BR>  }<BR> }<BR>}</P>
                  <P><BR></P></TD></TR></TBODY></TABLE><!-- InstanceEndEditable --></TD></TR></TBODY></TABLE></TD></TR>
  <TR vAlign=center bgColor=#eeeeee>
    <TD colSpan=3 height=28>
      <DIV align=center><A 
      onclick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.nuist.edu.cn')" 
      href="http://www.nuist.edu.cn/JSJ/syjx/xt/xt7.htm#"><SPAN 
      class=mb14>设为首页</SPAN></A><STRONG>|</STRONG><A class=mb14 
      href="javascript:addme()">加入收藏</A><STRONG>|</STRONG><A 
      href="http://www.nuist.edu.cn/"><SPAN 
      class=mb14>学校首页</SPAN></A><STRONG>|</STRONG><A 
      href="http://www.nuist.edu.cn/jsj"><SPAN 
    class=mb14>计科系首页</SPAN></A></DIV></TD></TR>
  <TR>
    <TD class=mb14 vAlign=top bgColor=#176bab colSpan=2 height=88>
      <DIV align=center><BR><FONT color=#ffffff>Copyright&copy; 2004-2005 Depart of 
      Computer Science &amp; Technology Nuist</FONT></DIV></TD>
    <TD width=15 bgColor=#176bab>&nbsp;</TD></TR>
  <TR>
    <TD height=1></TD>
    <TD width=581></TD>
    <TD></TD></TR></TBODY></TABLE><MAP name=Map><AREA shape=RECT coords=9,9,75,25 
  href="http://www.nuist.edu.cn/JSJ/syjx/index.htm"><AREA shape=RECT 
  coords=86,9,150,26 href="http://www.nuist.edu.cn/JSJ/syjx/jxdg.htm"><AREA 
  shape=RECT coords=157,9,220,27 
  href="http://www.nuist.edu.cn/JSJ/syjx/skja.htm"><AREA shape=RECT 
  coords=230,9,310,26 href="http://www.nuist.edu.cn/JSJ/syjx/dmt.htm"><AREA 
  onclick="MM_goToURL('parent','../xt.htm');return document.MM_returnValue" 
  shape=RECT coords=320,10,397,26 
  href="http://www.nuist.edu.cn/JSJ/syjx/xt.htm"><AREA 
  onclick="MM_showHideLayers('Layer1','','hide','Layer2','','show')" shape=RECT 
  coords=405,10,469,25 href="http://www.nuist.edu.cn/JSJ/syjx/xt/xt7.htm#"><AREA 
  onclick="MM_showHideLayers('Layer1','','show','Layer2','','hide')" shape=RECT 
  coords=476,10,538,26 href="http://www.nuist.edu.cn/JSJ/syjx/xt/xt7.htm#"><AREA 
  shape=RECT coords=549,10,612,26 
  href="http://www.nuist.edu.cn/JSJ/syjx/ckwx.htm"><AREA shape=RECT 
  coords=620,9,684,26 
href="http://www.nuist.edu.cn/JSJ/syjx/zlxz.htm"></MAP></CENTER><!-- InstanceEnd --></BODY></HTML>

⌨️ 快捷键说明

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