Thanks hk_mp5kpdw for the help with the referencing and cleaned up loop.
Code:
readData(infile, vector<int> itemID, vector<string> itemName, vector<int> pOrdered, vector<double> manufPrice, vector<double> sellingPrice);
This is my call of the function above which is producing the errors:
Code:
.\Project.cpp(34) : error C2275: 'std::vector<_Ty>' : illegal use of this type as an expression
with
[
_Ty=int
]
.\Project.cpp(34) : error C2146: syntax error : missing ')' before identifier 'itemID'
.\Project.cpp(34) : error C2059: syntax error : ')'
Below is all the relevent code that I am having problems with.
Code:
include "stdafx.h"
#include <iostream>
#include <vector>
#include <iomanip>
#include <string>
#include <fstream>
using namespace std;
void printHeading();
void printReport();
void readData(ifstream &inp,vector<int>, vector<string>,vector<int>,vector<double>,vector<double>);
int main()
{
vector <int> itemID(0);
vector <string> itemName(0);
vector <int> pOrdered(0);
vector <int> pInStore(0);
vector <int> pSold(0);
vector <double> manufPrice(0);
vector <double> sellingPrice(0);
ifstream infile;
infile.open("c:\\project.txt");
if (!infile)
{
cout << "Input file (project.txt) does "
<< "not exist." << endl;
return 1;
}
readData(infile, vector<int> itemID, vector<string> itemName, vector<int> pOrdered, vector<double> manufPrice, vector<double> sellingPrice);
infile.close();
infile.clear();
cout << itemName.size();
return 0;
}
void readData(ifstream& inp, vector<int>& itemID, vector<string>& itemName, vector<int>& pOrdered, vector<double>& manufPrice, vector<double>& sellingPrice)
{
int ID, Ordered;
string Name;
double mPrice, sPrice;
string goodinp;
while (inp >> ID >> Name >> Ordered >> mPrice >> sPrice)
{
itemID.push_back(ID);
itemName.push_back(Name);
pOrdered.push_back(Ordered);
manufPrice.push_back(mPrice);
sellingPrice.push_back(sPrice);
}
}