Employee Production Worker Problem

Hey guys, so I generated the header file for both the Employee and the Production worker classes and I created an array to pass arguments which worked nicely.

However, when I tried to cout them it wouldnt go...

Any idea how to get around this?

line 23: no operator "<<" matches these operands

thanks guys.

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
#pragma
#include <iostream>
#include <string>
#include <iomanip>
#include "Production Worker Header.h"

int main()
{
	const int NUM_WORKERS = 2;
	const int NUM_EMPLOYEES = 2;
	ProductionWorker : Employee Worker[NUM_WORKERS][NUM_EMPLOYEES] = 
	{
		ProductionWorker (1, 8), 
		Employee ("Benny Bryce", 01, 1182010),
		ProductionWorker (2, 10),
		Employee("Bobby Brown", 02, 5202010)
	};

	for (int i = 0; i < NUM_WORKERS; i++)
	{
		for (int i = 0; i < NUM_EMPLOYEES; i++)
		{
			std::cout << Worker[i][i];
		}
	}

	cin.ignore();
	cin.get();
}
Last edited on
The error means that you did not define the operator "<<" for the Employee class. Also, you use the same i for cycles over workers and employees. Bad idea
Yeah I figured it was. I decided to turn the Worker array into a pointer and set the arguments as "new" and I got a working program, also it took out the overloading operator problem.

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
#pragma
#include <iostream>
#include <string>
#include <iomanip>
#include "Production Worker Header.h"

int main()
{
	const int NUM_WORKERS = 4;
	ProductionWorker : Employee *Worker[NUM_WORKERS] = 
	{
		new ProductionWorker (1, 8), 
		new Employee ("Benny Bryce", 01, 1182010),
		new ProductionWorker (2, 10),
		new Employee("Bobby Brown", 02, 5202010)
	};

	for (int i = 0; i < NUM_WORKERS; i++)
	{
			std::cout << Worker[i];
	}

	cin.ignore();
	cin.get();
}


But the output just gives me random numbers now..

Last edited on
Topic archived. No new replies allowed.