-1

オーバーロードされた関数「表示」を使用してプログラムを作成しようとしています。今のところ大丈夫ですが、行き詰まっているようです。ここで自分のコードで何が間違っているのか理解できないようです。

#include <iostream>
#include <iomanip>
using namespace std;
int main()


{
    double small_num, large_num;
    double display;//I think the problem is here!!!

    cout <<"Please enter two number starting with the smallest, then enter the      largest"<<endl;

cin >> small_num;
cin >> large_num;
display(small_num, large_num);



system("pause");
return 0;
}

void display(int num1, int num2)
{
    cout << num1 <<" "<< num2 << endl;
    return;
}

void display(double num1, int num2)
{
    cout << num1 <<" "<< num2 << endl;
}

void display(int num1, double num2)
{
    cout << num1 <<" "<< num2 << endl;
}

void display(double num1, double num2)
{
    cout << num1 <<" "<< num2 << endl;
}
4

1 に答える 1

0

を削除しdouble display;ます。displayこれにより、関数名と競合するという名前の新しいローカル変数が作成されます。

また、次のいずれかです。

  • display上記の方法を入れてくださいmain
  • それらの定義をそのままにして、次のように main の上で宣言します。

    void display(int num1, int num2);
    void display(double num1, int num2);
    void display(int num1, double num2);
    void display(double num1, double num2);
    
于 2013-09-16T02:58:05.067 に答える