Inheritance w/read() and write()

Ok I've got most of this working except this one tiny part.

I've got a parent class called EmployeeClass and two child classes: Hourly and Salaried. I am writing and reading to/from a file. The parent class has a write/read function that covers the data that is relevant to both and the child classes have their own for their personal data(salary, hourly wage, and hours worked).
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
// Objects are supplied by the Teacher(who must be a H.P. fan)
Hourly h1(1, "H. Potter", "Privet Drive", "201-9090", 40, 12.00);

// This works for writing the data through the Hourly class
h1.writeData(employeeInput);

// Here's the Hourly::writeData()
// These two will write and read
void Hourly::writeData(ofstream& employeeInput)
{
		employeeInput << hourlyWage << endl;
		employeeInput << hoursWorked << endl;
}

// Here's the Hourly::readData()
bool Hourly::readData(ifstream& input) 
{
	 if (true)
	 {
		input >> hourlyWage; 
		input >> hoursWorked;
		return true;
	 }
	 else
	 {
		 return false;
	 }
}

// Here's the EmployeeClass::writeData()
void EmployeeClass::writeData(ofstream& employeeInput)
{
		employeeInput << employeeNumber << endl;
		employeeInput << employeeName << endl;
		employeeInput << streetAddress << endl;
		employeeInput << phoneNumber << endl;
}

// Here's the EmployeeClass::readData()
bool EmployeeClass::readData(ifstream& input)
{
	 if (true)
	 {
		input >> employeeNumber;
		input.ignore();
		getline(input,employeeName);
		getline(input,streetAddress); 
		getline (input,phoneNumber);
		return true;
	 }
         else
         {
               return false;
         }
}


When I call this piece of code in my program:h1.writeData(employeeInput); I need it to write through the use of both writeData functions.

{1, "H. Potter", "Privet Drive", "201-9090"} = Written to file through use of parent class
{40, 12.00) = followed by this being written to the same file through the use of the child class.

This is what the teacher stated in the assignment
Your Employee class also has a readData function and a writeData function. These will have to be modified slightly so that the functions only read and write the data common to both hourly and salaried employees. Then write a readData and WriteData method in each derived class. The derived class functions override the functions in the base class and should only read and write the data uniquely defined in their respective class, and call the base class readData and writeData functions to take care of the data that belongs to the base Employee class.


Any helpful hints are greatly appreciated.
Your Employee class also has a readData function and a writeData function. These will have to be modified slightly so that the functions only read and write the data common to both hourly and salaried employees. Then write a readData and WriteData method in each derived class. The derived class functions override the functions in the base class and should only read and write the data uniquely defined in their respective class, and call the base class readData and writeData functions to take care of the data that belongs to the base Employee class.
**Slapping forehead**

I see my error now. I was calling them wrong. Thanks for making that stick out a little more. Wow my eyes are tired.
Topic archived. No new replies allowed.