我正在嘗試使用其他類中的方法結果的值執行操作,我通過引用wingArea
值傳遞了值,並且我還嘗試使用方法span()
clsSpanCalculation
,但Xcode中顯示:「會員功能‘跨度’並不可行:‘這個’參數的類型爲‘常量clsSpanCalculation’,但funtion沒有被標記const的」將方法的引用值傳遞給另一個類
#include <stdio.h>
#include <cmath>
class clsSpanCalculation{
float wingArea, aspectRatio;
public:
clsSpanCalculation(){}
float get_wingArea(void)const{return wingArea;}
void set_wingArea(float Sw){wingArea = Sw;}
float get_aspectRatio(void)const{return aspectRatio;}
void set_aspectRatio(float AR){aspectRatio = AR;}
float span(){
float span;
span = sqrt(aspectRatio*wingArea);
return span;
}
};
class clsChordParameters{
float percentRectArea, percertTrapArea, taperRatio;
public:
float get_percentRectArea(void)const{return percentRectArea;}
void set_percentRectArea(float Srect){percentRectArea = Srect;}
float get_percentTrapArea(void)const{return percertTrapArea;}
void set_percentTrapArea(float Strap){percertTrapArea = Strap;}
float get_taperRatio(void)const{return taperRatio;}
void set_taperRatio(float lambda){taperRatio = lambda;}
float rootChord (const clsSpanCalculation &sC){
float rootChord, lambdaplus;
lambdaplus= taperRatio + 1;
rootChord = (2*(sC.get_wingArea()*(percentRectArea*(lambdaplus)+(2*percertTrapArea))))/((sC.span()*lambdaplus)/2);
return rootChord;
}
float tipChord (const clsSpanCalculation &sC){
float rootChord, tipChord, lambdaplus;
lambdaplus= taperRatio + 1;
rootChord = (2*(sC.get_wingArea()*(percentRectArea*(lambdaplus)+(2*percertTrapArea))))/((sC.span()*lambdaplus)/2);
tipChord = rootChord*taperRatio;
return tipChord;
}
};
下面是代碼行的Xcode顯示在其中消息:
rootChord = (2*(sC.get_wingArea()*(percentRectArea*(lambdaplus)+(2*percertTrapArea))))/((sC.span()*lambdaplus)/2);
我會很感激的幫助。