こんにちは私は学校のプロジェクトに取り組んでおり、このコードをすべてゼロから作成しています。私は、2つ以外のすべてのエラーを解決したので、ちょっと混乱しています。誰かが私のソースコードを見て、私が間違っていることと解決方法を教えてくれるのだろうかと思っていました。ありがとう!ここで戻り値の型だけで区別される関数をオーバーロードできないC++
はエラー
の存在に "のstd ::文字列" からノー適した変換関数:戻り値の型だけでIntelliSenseのです: "ダブル"
のIntelliSenseで区別機能をオーバーロードすることはできません
そして私のソースコード。
#include <iostream>
#include <string>
using namespace std;
//Global Constants
const double BMI_FACTOR = 703;
const double MASS_LOWER_LIMIT = 18.5;
const double MASS_UPPER_LIMIT = 25.0;
//Function Prototypes
double getWeight();
double getHeight();
double setMass(double, double);
string setOverUnder(double);
void showBMI(string, double);
//Begin Main
int main() {
//Variable Declaration
double weight;
double height;
double BMI; //Body Mass Index
string healthStatus; //Either Optimal, Under, or Over-weight
//Get the user's weight
weight = getWeight();
//Get the user's height
height = getHeight();
//Calculate the user's BMI
BMI = setMass(weight, height);
//Determine the user's health status based on BMI
healthStatus = setOverUnder(BMI);
//Displays the user's BMI and health status
showBMI(healthStatus, BMI);
return 0;
//End Main
}
//Function getWeight
double getWeight() {
//Local Variable Declaration
double totalWeight;
//User Input for Weight
cout << "Enter weight in pounds." << endl;
cin >> totalWeight;
//Return the value for totalWeight to caller
return totalWeight;
//End Function getWeight
}
//Function getHeight
double getHeight() {
//Local Variable Declaration
double totalHeight;
//User Input for Height
cout << "Enter height in inches." << endl;
cin >> totalHeight;
//Return the value for totalHeight to caller
return totalHeight;
//End Function getHeight
}
//Function setMass
double setMass(double localVarWeight, double localVarHeight) {
//Local Variable Declaration
double totalMass;
//Calculate the user's BMI
totalMass = (localVarWeight * BMI_FACTOR)/(localVarHeight * localVarHeight);
//Return the value of totalMass to the caller
return totalMass;
//End Function setMass
}
//Function setOverUnder
double setOverUnder(double localVarMass) {
//Local Variable Declaration
string wellBeing;
//Determine user's health
if (localVarMass < MASS_LOWER_LIMIT)
wellBeing = string("underweight.");
else if (localVarMass > MASS_UPPER_LIMIT)
wellBeing = string("overweight.");
else
wellBeing = string("optimal weight.");
//Return the value of wellBeing to the caller
return wellBeing;
//End Function setOverUnder
}
//Function showBMI
void showBMI(string localVarHealth, double localVarMass) {
//Display user's BMI
cout << "Your BMI is " << localVarMass << endl;
//Display user's health status
cout << "You are " << localVarHealth << endl;
//End Function showBMI
}
ここにダンプしたコードのどの行がこのエラーを生成しているのですか?おそらく、より具体的に問題を説明すると、人々があなたを手助けするのがより簡単になるでしょう。 –