Help with a function that brings in a stream object

Hey everyone,
I need help with a program I'm writing for my C++ class and I'm totally stuck.
I'm supposed to add two new functions to an existing class that I've written early on: readData(ifstream&)and writeData(ofstream&).
The parameters of the program are:
-Create three employee objects as shown,
-Create an ofstream object and open a file. Choose any name for the file that you want. Do not ask the user for the file name. Pass just the file name as the parameter (no path) so that your program assumes the file to be in the same folder as your executable file.
-Send messages to each of the three Employee objects to write themselves out to the file.
-Close the file.
...
If I get help on the writeData(ofstream&) function bit that would really help! for brevity I've cut all the functions of the class that arent necessary

Here's what I have so far:
Employee.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#pragma once
#include<string>
using namespace std;

//This class models an employee. It contains key information
//about an employee and functions to manage that data.

class Employee
{

private:
	int employeeNumber;
	string name, address, phoneNumber;
	double hourlyWage, hoursWorked;

public:

	Employee();
	Employee(int, string, string, string, double, double);
        //readData function
	//Purpose: to read the data of an ifstream
	//Parameters: the ifstream object referred to by &
	//Returns: none
	void readData(ifstream&) const;
	//writeData function
	//Purpose: to output the data of a stream object
	//Parameters: the ofstream object referred to by &
	//Returns: none
	void writeData(ofstream&) const;
};

Employee.cpp
1
2
3
4
5
6
#include "Employee.h"


	void Employee::readData(ifstream&)const{}
	void Employee::writeData(ofstream&)const{}

Driver.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "Employee.h"
#include <iostream>
#include <fstream>
#include<string>

using std::ofstream;
using std::ios;
using namespace std;

int printCheck(const Employee& newObj)
{
	cout << "\n----------FluffShuffle Electronics----------";
	cout << "\n\nPay to the order of " << newObj.getName() << ".............$" << newObj.calcPay() << endl;
	cout << "\nUnited Bank of Eastern Orem\n--------------------\n\nHours worked: " << newObj.getHoursWorked();
	cout << "\nHourly wage: " << newObj.getHourlyWage() << endl;
	return 0;
}

int main()
{
	cout.setf(ios::fixed);			//formatting our doubles
	cout.setf(ios::showpoint);
	cout.precision(2);

	string nameOne = "Joe Brown", nameTwo = "Sam Jones", nameThree = "Mary Smith", addressOne = "123 Main St.", addressTwo = "45 East State", addressThree = "12 High Street", phoneOne = "123-6788", phoneTwo = "661-9000", phoneThree = "401-8900";	//our object values
	const int AGE_ONE = 45, AGE_TWO = 30, AGE_THREE = 40, EMP_ONE= 37, EMP_TWO=21, EMP_THREE=15;
	const double RATE_ONE = 10.00, RATE_TWO = 12.00, RATE_THREE = 15.00;

	int optionOne = 1,optionTwo = 2; //menu variables
	int choice;						
	string bufferFlush = "";



	/*	Presents the user with a menu of choices:	
		-create a data file, or read data from a file and print checks.*/
	cout << "\nThis program has two options:\n1 - Create a data frile, or\n2 - Read data from a file and print paychecks.\nPlease enter (1) to create a file or (2) to print checks:\t";
	while (!(cin >> choice)){
		cin.clear();
		cout << "\nInvalid input occured."; // output error message
		cin >> bufferFlush; //get string out of cin
		cout << "\nPlease enter a valid option, either 1 or 2:  ";
	}
	if (choice == One){
		
		Employee joe(EMP_ONE, nameOne, addressOne,phoneOne,AGE_ONE,RATE_ONE);//Create three employee objects
		Employee sam(EMP_TWO, nameTwo, addressTwo, phoneTwo, AGE_TWO, RATE_TWO);
		Employee mary(EMP_ONE, nameThree, addressThree, phoneThree, AGE_THREE, RATE_THREE);
		
		ofstream myOutputStream("mydata.txt");//Create an ofstream and opoen a file.
		
		


	}
	else if (choice == optionTwo){

	}

	system("PAUSE");
	return 0;
} 


So I've tried a bunch of different ways to get my objects into the ofstream object to write them to the file, but I'm supposed to use the two new functions somehow...but I'm way lost. Any help would be appreciated.
So this is my new edit on this problem:
Employee.cpp
1
2
3
4
5
void Employee::writeData(ofstream& stream, Employee& newObj)const{
stream << newObj.getEmpNumb() << " " << newObj.getName() << " " 
<< newObj.getAddress() << " " << newObj.getHourlyWage << " " 
<< newObj.getHoursWorked();
	}


Although I'm getting an error under the first << operator. It says "Error:no operator "<<" matches these operands operand types are: std::ofstream<<int
Is getHourlyWage a variable or a function?

As a side note, I don't see the point of passing another Employee object to a member function. You'd just use the Employee on which the function is called.
You're right, there was a typo in the text. it is a newObj.getHourlyWage()

Didn't quite understand what you meant in your side note xD I'm still fairly new to programming.
Is this what you meant:

Employee.cpp
1
2
void Employee::writeData(ofstream& stream)const{
		stream <<getEmpNumb() << " " << getName() << " " << getAddress() << " " << getHourlyWage() << " "<<getHoursWorked();}

Driver.cpp
1
2
3
Employee joe(EMP_ONE, nameOne, addressOne,phoneOne,HOURS_ONE,RATE_ONE);
ofstream myOutputStream("mydata.txt", ios::app);
joe.writeData(myOutputStream);
Yes, exactly that.
Topic archived. No new replies allowed.