标题:新手一枚。请教大家一下,为什么编译成功,但显示不出结果呢?
取消只看楼主
airfeel
Rank: 1
来 自:湖南
等 级:新手上路
帖 子:2
专家分:0
注 册:2013-4-24
 问题点数:0 回复次数:1 
新手一枚。请教大家一下,为什么编译成功,但显示不出结果呢?
#include "iostream"

using namespace std;

class shape {
      public:
             shape(){}
              virtual  double perimeter() {}
              virtual double   area (){}
             };
class rectangle:public shape {
      public:
             rectangle (double w,double h){width=w;height=h;}
            virtual  double perimeter(){return (width+height)*2;}
             virtual  double  area() {return width*height;}
        private:
                double width,height;
                };
const double PI=3.1415926;
class circle:public shape{
      public:
             circle(double r){radius=r;}
            virtual  double  perimeter() {return radius*PI*2;}
             virtual double  area() {return radius*radius*PI;}
      private:
              double radius;
              };
double sum(shape &s1,shape &s2)
{return s1.area()+s2.area();}

int main(){
    rectangle r1(14,12),r2(8,6);
    circle c1(4),c2(5);
    sum(r1,c1);
   
  sum(r1,r2);   
 system("PAUSE");

 return EXIT_SUCCESS;
 }
搜索更多相关主题的帖子: private include public 
2013-04-26 22:13
airfeel
Rank: 1
来 自:湖南
等 级:新手上路
帖 子:2
专家分:0
注 册:2013-4-24
得分:0 
回复 2楼 qiaosl
谢谢啦、后来自己弄清了、
2013-05-14 22:13



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-405634-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.049894 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved