Hello,
I am new at this. I am trying to work with calling functions here. (Eventually I want to do some simple calcs on cost of going through a station...)but am getting an error on line marked with *****
initialise line within main int(). Can someone kindly suggest why it gives me error: "invalid initialisation of reference of type 'double&' from expression of type 'float'. (I have checked that all my function floats and doubles match up correctly)....
Thanks in advance for your help.
#include <iostream>
#include <string.h>
using namespace std;
void initialise(float&, double& ,int& ,int& ,bool&);
void printPageHeadings(int&, int&);
void readRecord (int&, string& , int&, float&, int&, bool&);
void printControlCost(string, float& , int& );
void processRecord(int ,string ,int,float,int ,float& ,float&,int);
void printDetailLine (int ,string ,int ,float ,int ,float , int&);
void resetControlTotals(float&);
void accumulateTotals(float , float&, float& );
const int MAX_DETAIL_LINES =100;
void initialise(float& controlTotal,double& invoiceTotal,int& pageCount,int& lineCount,bool& more)
{
controlTotal = 0;
invoiceTotal = 0;
pageCount = 0;
lineCount = 0;
more= true;
}
void printPageHeadings(int& pageCount, int& lineCount)
{
pageCount = pageCount +1;
cout<<"TAG\tPERSON'S\tSTATION"
<<"\t\t\t\t\n";
cout<<"ID\tNAME\t\tID\t\tCOST\t\QTY\tAMOUNT\n\n";
lineCount = 4;
}
void readRecord (int& id, string& name, int& item, float& cost, int& qty, bool& more)
{
cerr<<"-->";
cin>>id>>name;
cin>>item>>cost>>qty;
more =! cin.fail() && id;
//validateName(name);
}
//void validateName(string name)
//{
// static string pad= " ";
// name = name + pad + pad +pad;
//name= name.substr(0,3*TABWIDTH-1);
//}
void printControlCost(string prevName, float& controlTotal, int& lineCount)
{
cout<<"\t\tTotal Cost for "<<prevName;
cout<<"\t$"<<controlTotal<<"\n\n";
lineCount = lineCount + 2;
resetControlTotals(controlTotal);
}
void processRecord(int id,string name,int item,float cost,int qty,float& controlTotal,float& invoiceTotal,int lineCount)
{
float amount;
amount = cost * qty;
printDetailLine (id, name, item, cost, qty, amount, lineCount);
accumulateTotals(amount, controlTotal, invoiceTotal);
}
void printDetailLine (int id,string name,int item,float cost,int qty,float amount, int& lineCount)
{
cout<<id<<"\t\t"<<name<<"\t"
<<item<<"\t$"<<cost<<"\t"
<<qty<<"\t$"<<amount<<"\n";
lineCount++;
}
void resetControlTotals(float& controlTotal)
{
controlTotal = 0;
}
void accumulateTotals(float amount, float& controlTotal, float& invoiceTotal)
{
controlTotal =controlTotal + amount;
invoiceTotal = invoiceTotal + controlTotal;
}
int main()
{
int id;
string name;
int item;
float cost;
int qty;
bool more;
float controlTotal;
float invoiceTotal;
int pageCount;
int lineCount;
int prevId;
string prevName;
*********initialise (controlTotal, invoiceTotal, pageCount, lineCount, more);
printPageHeadings(pageCount, lineCount);
readRecord(id, name, item, cost, qty, more);
prevId =id;
prevName=name;
while(more)
{
if (id!=prevId)
printControlTotalCost(prevName, controlTotal, lineCount);
prevId= id;
prevName = Name;
}
if (lineCount >MAX_DETAIL_LINES)
printPageHeadings(pageCount, lineCount);
precessRecord(id, name, item, cost, qty, controlTotal, invoiceTotal, lineCount);
readRecord(id, name, item, cost, qty, more);
printControlTotalCost(prevName, controlTotal, lineCount);
printReportTotals(invoiceTotal);
system("pause");
return 0;
}