-1
所以我想編譯所以我可以運行我的第一個函數,看看它是否正常工作,但我不斷收到這些錯誤。請幫忙!我得到的錯誤:C++中引用的初始化無效
「的從類型‘字符’的表達類型的參考‘司&’無效初始化」我也得到「在傳遞的`空隙Create_Corporate_File參數1(司&司&,司&,司&)'」
#include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;
const int SIZE = 12;
struct Division
{
char divName [SIZE];
double sales [4];
};
int main()
{
char Div_E;
char Div_W;
char Div_N;
char Div_S;
void Describe_Program();
void Create_Corporate_File (Division& Div_E, Division& Div_W, Division& Div_N, Division& Div_S);
//void Display_Corporate_Sales (Div_E, Div_W, Div_N, Div_S);
Describe_Program();
Create_Corporate_File (Div_E, Div_W, Div_N, Div_S);
system ("PAUSE");
return 0;
}
void Describe_Program()
{
cout << "This program will prompt you to enter the sales amount\n";
<< "for each quarter of the North, South, West and East Division.\n";
<< "After you enter the sales amount for each quarter, the program\n";
<< "will be able to calculate the total quarterly sales for that";
<< "division";
<<endl<endl;
return;
}
void Create_Corporate_File (Division& Div_E, Division& Div_W, Division& Div_N, Division& Div_S)
{
fstream quarterly_sales;
quarterly_sales.open ("quarterly_sales.dat" ios::out|ios::binary)
For(div = 0, div < 4, div++)
{
Division temp;
if (div == 0)
temp = Div_E;
else
if (div == 1)
temp = Div_W;
else
if (div == 2)
temp = Div_N;
else
temp = Div_S;
cout << "Please enter the division: ";
cin.getline (temp.divName, SIZE);
For(sales = 0, sales < 4, sales++)
{
cout << "Please enter the sales amount for quarter " << sales + 1 <<":\n";
cin >> temp.sales [sales];
}
}
將'char Div_E;'改爲'Division Div_E;'等等。 – 2014-10-30 20:59:20
你的代碼中有許多其他的錯誤(btw)。 – Borgleader 2014-10-30 21:05:15