|
-
November 11th, 2009, 08:44 PM
#1
no match for operator >> in?
For some reason, right when i get to the part where i'm getting the data for the persons ID and name and such... it keeps on saying that there's not match for operator >> in.
What does that mean and what's going wrong with it?
It's in the function:
void hireOne (employeeType list[], int& listSize, employeeType& person)
// Gabriel Quinto and Pernell Dixon Jr.
// CRN: 11051
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
struct employeeType;
struct employeeType
{
int id;
string first;
string last;
char gender;
double payrate;
int dependents;
};
const int MAX_EMPLOYEES = 50;
void getData(ifstream& inFile, employeeType list[], int& listSize);
void printList(employeeType list[], int listSize);
void printOne (employeeType one);
employeeType getOne (ifstream& dataIn);
employeeType newEmployee (employeeType&);
void selectionSort(employeeType list[], int listSize);
void hireOne(employeeType list[], int& listSize, employeeType&);
int main()
{
employeeType him;
employeeType her;
employeeType newemp;
employeeType list [MAX_EMPLOYEES];
int listSize = 0;
char choice;
ifstream dataFile;
dataFile.open ("Employees.txt");
if (!dataFile)
{
cout << "Don't work\n\n";
system ("pause");
return 1;
}
getData(dataFile, list, listSize);
printList( list, listSize);
cout << "\nNew employee him" << endl;
newEmployee (him);
cout << "\nNew employee her" << endl;
newEmployee (her);
printOne (him);
printOne (her);
hireOne (list, listSize, newemp);
printList (list, listSize);
selectionSort (list, listSize);
printList (list, number);
system("pause");
return 0;
}
///////////////////////////////////////////////////////////
void getData(ifstream& inFile, employeeType list[], int& listSize)
{
employeeType item;
listSize = 0;
item = getOne (inFile);
while (inFile)
{
list [listSize] = item;
listSize++;
item = getOne (inFile);
}
inFile.close ();
}
////////////////////////////////////////////////////////////
//Print out the list of employeeType structs
void printLIst(employeeType list[], int listSize)
{
int looper;
for (looper = 0; looper < listSize ; looper++)
{
printOne(list [looper] );
cout << endl;
}
}
/////////////////////////////////////////////////////////////
//Input for one employee from the input file
employeeType getOne (ifstream& dataIn)
{
employeeType one;
dataIn >>one.first >> one.last>>one.gender>>one.id>>one.payrate>>one.dependents;
return one;
}
/////////////////////////////////////////////////////////////////
//print out one menuItemType struct
void printOne (employeeType one)
{
cout << fixed << showpoint << setprecision (2);
cout << "\n\nID " << one.id << endl;
cout << "Name: " <<one.first << " " << one.last<< endl;
cout << "gender: " << one.gender << endl;
cout << "payrate $" << one.payrate << " \nnumber of dependents: " << one.dependents << endl;
}
/////////////////////////////////////////////////////////////
employeeType newEmployee (employeeType& employee)
{
cout << "\nEnter ID, first, last: " << endl;
cin >> employee.id >> employee.first >> employee.last;
cout << "\nEnter gender, payrate, and number of dependents: " << endl;
cin >> employee.gender >> employee.payrate >> employee.dependents;
}
////////////////////////////////////////////////////////////////////
void hireOne (employeeType list[], int& listSize, employeeType& person)
{
employeeType temp;
int index = 0;
cout << "\n Please enter an ID: " << endl;
cin >> person.id >> endl;
cout << "\nPlease enter a first and last name: " << endl;
cin >> person.first >> person.last >> endl;
cout <<"\nPlease enter a gender (M/F): " << endl;
cin >> person.gender >> endl;
cout << "\nPlease enter a payrate: " << endl;
cin >> person.payrate >> endl;
cout << "\nPlease enter the number of depentends: " << endl;
cin >> person.dependents >> endl;
cout << "\nPlease enter the index for new employee: ";
cin >> index;
temp = list[index];
list[index] = person;
list[listSize+1] = temp;
cout << " list size = " <<listSize;
listSize++;
}
////////////////////////////////////////////////////////////
void selection (employeeType list[], int listSize)
{
int largestIndex;
int minIndex;
employeeType temp;
for (int i = 0; i < listSize -1; i++)
{
largestIndex = i;
for (minIndex = i + 1; minIndex < listSize; minIndex++)
if (list[minIndex].payrate>list[largestIndex].payrate)
largestIndex = minIndex;
temp = list[largestIndex];
list[largestIndex] = list[i];
list[i] = temp;
}
}
////////////////////////////////////////////////////////////
void raiseTime (employeeType list[], int& listSize)
{
for (int i = 0; i < listSize; i++)
{
list[i].payrate += list[i].payrate*.10;
}
}
-
November 11th, 2009, 09:03 PM
#2
Re: no match for operator >> in?
Try removing the ">>endl" from "cin"
-
November 11th, 2009, 09:08 PM
#3
Re: no match for operator >> in?
ahhh, thank you... that worked.
But now i'm getting an error saying:
unidentified reference to 'printList(employeeType*, int)'
I know this is another problem, but i think this is the last error.... shot
-
November 11th, 2009, 09:16 PM
#4
Re: no match for operator >> in?
Maybe this...
Code:
printList (list, number);
Where is number declared?
Also, get rid of this...
Code:
using namespace std;
It makes life very difficult in the long run...
-
November 11th, 2009, 09:29 PM
#5
Re: no match for operator >> in?
also check the spelling
Code:
printList (list, number);
vs
printLIst (list, number);
-
November 11th, 2009, 10:06 PM
#6
Re: no match for operator >> in?
Good catch, i missed that one
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|