まずはこれは私の最初の質問stackoverflowです。私は宿題を完成しようとしていますが、何が間違っているのか分かりません。C++奇妙なエラー "intから 'int(__cdecl *)(float、float)への変換なし" "
2回目の関数を実行しようとすると「intから__cdecl *(float、float)に変換されません」というエラーが発生します。この関数は0、-1、または+1のいずれかを返すと仮定され、それはif/else文で使用されます。ここで私が参照しているコードの塊だ
...
#include <iostream>
using namespace std;
////this function returns a -1 if the left pan has a weight more than the right, a 0 if the weights of the two pans are equal, and a +1 if the right pan has a greater weight than the left
int weigh(float leftpan, float rightpan)
{
//compare the pan weights, return value
}
float findOddRock(float r1, float r2, float r3, float r4, float r5, float r6, float r7)
{
//first weigh
float first_leftpan = r1 + r2;
float first_rightpan = r3 + r4;
weigh(first_leftpan, first_rightpan);
if(weigh == 0){
cout << "this program is working so far";
float second_leftpan = r5; //this brings up an error for some reason
float second_rightpan = r6;
weigh(second_leftpan, second_rightpan);
//here's where I get the error, no conversion from 'int' to 'int (__cdecl *)(float,float)'
if(weigh == 0){ //be careful here, changed from second_weigh to weigh
float third_leftpan = r5;
float third_rightpan = r7;
weigh(third_leftpan, third_rightpan);
}
//
int main()
{
//find the light rock
findOddRock(2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 1.0);
}
私はアドバイスを受け取りましたが、今度はプログラムが実行されますが、findOddRockは含まれている文字列を返しません。いずれかの文字列を返さない関数の問題は何ですか? – Charli