Urgent!!! Error with cout!

Need help. Getting error: no operator "<<" matches these operands at line 36.

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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include "stdafx.h"
#include <string>
#include <iostream>
#include <ostream>
using namespace std;

struct Date
{
	int day;
	int month;
	int year;
};

struct Employee
{ 
		Date  birthdate;
		int age;
		int id;
		float salary;
		int getAge( ) { return age; };
		int getId( )  {return id; };
		float getSalary( ) {return salary; };
        Date getBirthdate( ) { return birthdate;};
}company[3];

void PrintEmployee(Employee comapany[], int len,int lowOne= company[2].salary, int lowTwo = company[2].age,int highOne= company[1].salary, int highTwo= company[1].age)
{

	for (int i=0;i<len;i++) //for loop
	{
		cout << "\nEmployee " << i + 1 << endl;
		cout << "-----------" << '\n';
		cout << "Age: " <<company[i].age << endl;
		cout << "Id: " << company[i].id << endl;
		cout << "Salary: " << company[i].salary << endl;
		cout << "BirthDate: " << company[i].birthdate << endl;
		cout << "==========================" << '\n';
	}

	for(int i=0;i<len;i++)
	{
		if(company[i].age> highTwo)
		{
			highTwo= company[i].age;
		}
		
		if(company[i].salary > highOne)
		{
			highOne =company[i].salary;
		}
		
		
	}
	for(int i=0;i<len;i++)
	{
		if(company[i].salary <= lowOne)
		{
			lowOne = company[i].salary;	
		}
		
		if(company[i].age <= lowTwo)
		{
			lowTwo = company[i].age;
		}
	}
	cout << "The highest salary is : " << highOne << endl;
	cout<< "The lowest salary is: "<<lowOne<<endl;
	cout<< "The highest age is: " <<highTwo << endl;
	cout<< "The lowest age is: " <<lowTwo <<endl;
}
	
	

void main()
{

	company [0].id = 30042554; // set the values for the two elements of the array
	company [0].age = 30;
	company [0].salary = 50000.00;
	company [0].birthdate.day = 15;
	company [0].birthdate.month = 01;
	company [0].birthdate.year = 1985;

	company [1].id = 40041002;
	company [1].age = 45;
	company [1].salary = 70000.00;
	company [1].birthdate.day = 13;
	company [1].birthdate.month = 02;
	company [1].birthdate.year = 1990;

	company [2].id = 50051003;
	company [2].age = 25;
	company [2].salary = 30000.00;
	company [2].birthdate.day =30;
	company [2].birthdate.month = 10;
	company [2].birthdate.year = 1991;


	PrintEmployee(company, 3); // call PrintEmployee( ) with a proper parameter list
	cin.get();
}
birthdate is an object. What is exactly do you want to print? to access to the day variable, you simply do
company[i].birthdate.day
(and so on for month and year.) but you can't print an object. The object represents an entity which has a variety of elements.
Last edited on
You already have a thread discussing this problem. Please don't spam the forums with multiple threads for the same topic.
Thanks. I didn't know I had to output each member it currently works thank you!
but you can't print an object.

This is not true. You can overload the << operator for type Date, to do exactly that.
Last edited on
As MikeyBoy said, please don't make another post for the same issue.
If you need to draw attention to a question you've asked, it's OK to bump the thread, within reasonable limits. Better to do that than to clutter the forum with multiple threads, which splits the discussion on a topic over several threads and wastes people's time answering questions which have been answered in other threads.
Sorry I just thought if I put my other problem into a different thread then I would possibly get someone else that could possibly answer it. I didn't mean to break a forum rule lol. I was just trying to think smart. I'm new to this whole forum thing.
No worries - just wanted to let you know the best way to go about things in the future.
Topic archived. No new replies allowed.