참조 매개 변수에 문제가 있습니다. getStockInfo
의 값은 참조 매개 변수에 저장되어 있습니다. 그걸 어떻게 해야할지 모르겠다. 그래서 displayStatus
을 인자로 받아 들인다. 내가 메인에 getStockInfo
에 뭔가를 집어 넣을 때마다 나는 에러 More than one onstance of overloaded function "getStockInfo" matches the argument list
을 준다.C++ 참조 매개 변수 함수
#include <iostream>
#include <iomanip>
using namespace std;
void getStockInfo(int &, int&, double&);
void displayStatus(int &, double &);
int main()
{
int spoolsOrdered;
int spoolsStock;
double specialCharges;
cout << "Middletown Wholesale Copper Wire Company" << endl;
getStockInfo(spoolsOrdered, spoolsStock, specialCharges);
}
void getStockInfo(int &spoolsOrdered, int &spoolsStock, double specialCharges)
{
char ship;
cout << "How many spools would you like to order: ";
cin >> spoolsOrdered;
//Validate the spools ordered
while(spoolsOrdered < 1)
{
cout << "Spools ordered must be at least one" << endl;
cin >> spoolsOrdered;
}
cout << "How many spools are in stock: ";
cin >> spoolsStock;
//Validate spools in stock
while(spoolsStock < 0)
{
cout << "Spools in stock must be at least 0" << endl;
cin >> spoolsStock;
}
cout << "Are there any special shipping charges? ";
cout << "Enter Y for yes or another letter for no: ";
cin >> ship;
//Validate special charges
if(ship == 'Y' || ship == 'y')
{
cout << "Enter the special shipping charge: $";
cin >> specialCharges;
}
else
{
specialCharges = 10.00;
}
}
void displayStatus(int &backOrder, double &subtotal, double &shipping, double &total)
{
}
코드에서 getStockInfo' '의 두 곳을보고 비교 대. – chris
함수 프로토 타입, 둘 다 및 실제 정의를 살펴보십시오. 그들은 평등하지 않습니다. –