このコードに問題があり、
#include <iostream>
#include <conio.h>
using namespace std;
class Circle {
double x, y, r;
public:
Circle (double a=1.0, double b=1.0, double c=1.0) { x=a; y=b; r=c; }
~Circle() {}
double Area();
double getRadius();
};
class Conus {
double height;
Circle C;
public:
Conus (double , double , double , double );
~Conus() {};
double Volume();
void setRadius(double );
};
Conus::Conus(double h, double a, double b, double c)
: C (a, b, c)
{
height=h;
}
double Circle::Area() { return r*r*3.14; }
double Conus::Volume() { return C.Area()*height; }
double Circle::getRadius() { return r; }
void Conus::setRadius(double t ) { C.getRadius()=t; }
int main() {
double a=2.4, b=3.5, r=5.4, h=5.9;
Circle Wre (a, b, r) ;
Conus Konusi (h, a, b, r) ;
cout << "Wris centris koordinatebia: " << a << " da " << b << ", radiusi: " << r
<< ". Wris fartobia :" << Wre.Area() << endl;
cout << "Konusis fudzis centris koordinatebia: " << a << " da " << b << ", radiusi: " << r
<<endl<< "konusis moculobaa: " << Konusi.Volume() << endl;
Konusi.setRadius(r+3);
cout << Konusi.Volume() << endl;
_getch();
return 0;
}
C.getRadius() は変更可能な左辺値ではないと言っています。誰か助けてください..