有問題,此代碼幫助,請在此C++代碼(修改的左值)
#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()是不可修改的左值。是否有人可以幫助..
查看FAQ http://stackoverflow.com/faq。它可以幫助你發佈更多可以幫助你的人獲得關注的問題。 –
我想回答「你正試圖給一個函數賦值」,但後來我意識到你可以用C++來做到這一點。 – Detheroc