主题:郁闷呀!C++
#include<iostream.h>
#include<math.h>
class CCircle
{public:
//CCircle(double r){}
virtual void Area();
virtual void Volume();
protected:
double radius;
};
class CSphere:public CCircle
{public:
CSphere(double r){radius=r;}
void Area()
{
area=4*3.14*pow(radius,2);
cout<<"Area="<<area<<endl;
}
void Volume()
{
volume=4/3*3.14*pow(radius,3);
cout<<"Volume="<<volume<<endl;
}
protected:
double area,volume;
};
class CColumn:public CCircle
{public:
CColumn(double h,double r){radius=r;height=r;}
void Area()
{
area=2*3.14*(radius*height+pow(radius,2));
cout<<"ColumnArea="<<area<<endl;
}
void Volume()
{
volume=3.14*pow(radius,2)*height;
cout<<"CloumnVolume="<<volume<<endl;
}
private:
double area,volume,height;
};
void main()
{CSphere a(2);
CColumn b(2,5);
CCircle *p=&a;
p->Area();
p->Volume();
p=&b;
(*p).Area();
(*p).Volume();
}
..这个程序在compile的时候没有错误,却在build的时候出现错误了,麻烦高手帮帮忙。
#include<math.h>
class CCircle
{public:
//CCircle(double r){}
virtual void Area();
virtual void Volume();
protected:
double radius;
};
class CSphere:public CCircle
{public:
CSphere(double r){radius=r;}
void Area()
{
area=4*3.14*pow(radius,2);
cout<<"Area="<<area<<endl;
}
void Volume()
{
volume=4/3*3.14*pow(radius,3);
cout<<"Volume="<<volume<<endl;
}
protected:
double area,volume;
};
class CColumn:public CCircle
{public:
CColumn(double h,double r){radius=r;height=r;}
void Area()
{
area=2*3.14*(radius*height+pow(radius,2));
cout<<"ColumnArea="<<area<<endl;
}
void Volume()
{
volume=3.14*pow(radius,2)*height;
cout<<"CloumnVolume="<<volume<<endl;
}
private:
double area,volume,height;
};
void main()
{CSphere a(2);
CColumn b(2,5);
CCircle *p=&a;
p->Area();
p->Volume();
p=&b;
(*p).Area();
(*p).Volume();
}
..这个程序在compile的时候没有错误,却在build的时候出现错误了,麻烦高手帮帮忙。