新手一枚。请教大家一下,为什么编译成功,但显示不出结果呢?
#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;
}