LocationData、PointTwoD、および MissionPlan の 3 つのクラスがあります。クラス MissionPlan は、すべてのプログラムを実行するドライバー クラスです。私の LocationData には、ユーザーから 5 つの入力を受け取る静的メソッドがあり、フロートに計算して値を返します。前に述べたように、MissionPlan はドライバー クラスであり、すべての入力は MissionPLan クラスにリンクされます。MissionPlan で静的メソッド呼び出しを実行して、値 LocationData::computeCivIndex(s,i,j,k, l); しかし、それは私に非常に長いエラーを返します。
/tmp/ccK8Rwha.o: 関数MissionPlan::MissionPlan()':
test.cpp:(.text+0x9f1): undefined reference to
LocationData::computeCivIndex(std::basic_string, std::allocator >, int, int, float, float) 内 /tmp/ccK8Rwha.o: 関数 `MissionPlan::MissionPlan() 内':
test.cpp:(.text+0xfb7): `LocationData::computeCivIndex(std::basic_string, std::allocator >, int, int, float, float)' への未定義の参照 collect2: ld が 1 つの終了ステータスを返しました
class LocationData
{
private:
//codes for initilization
public:
LocationData();
LocationData(string,int,int,float,float);
//getter and setter methods..
static float computeCivIndex(string,int,int,float,float);
};
class MissionPlan
{
public:
MissionPlan();
};
static float computeCivIndex(string sunType, int noOfEarthLikePlanets,int noOfEarthLikemoons, float aveParticulateDensity, float avePlasmaDensity)
{
LocationData data; //not sure if i need this
//methods to caculate...
float ci = 0.0;
return ci;
}
MissionPlan::MissionPlan()
{
int choice; // to capture what user inputs into menu
int count=0;
//codes to get user inputs
cin>>choice;
for(;;)
{
if(choice == 1)
{
int i,j,x,y;
float k,l;
string s;
//codes to get user inputs
LocationData::computeCivIndex(s,i,j,k,l); //the part where error occurs
count++;
}
else if(choice == 2)
{
cout<<"Computation completed!"<<endl;
break;
}
else if(choice==3);
else if(choice==4);
else
cout<<"Please enter number 1 to 4 only!"<<endl;
}//end of do loop
}//end of MissionPlan()
int main()
{
MissionPlan plan;
MissionPlan();
return 0;
}