Illegal Expression Error

Current Problem; I'm getting an "Illegal expression error"

Prompt; 10. Corporate Sales Data
Write a program that uses a structure named CorpData to store the following information
on a company division:
Division name (such as East, West, North, or South)
First quarter sales
Second quarter sales
Third quarter sales
Fourth quarter sales

Include a constructor that allows the division name and four quarterly sales amounts to be specified at the time a CorpData variable is created.
The program should create four CorpData variables, each representing one of the
following corporate divisions: East, West, North, and South. These variables should be
passed one at a time, as constant references, to a function that computes the division’s
annual sales total and quarterly average, and displays these along with the division name.

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
#include <iostream>
#include <string>
using namespace std;

struct CorpData
{
	string name;
	double first, second, third, fourth, total, avg;

	CorpData(string n = "", double f = 0, double s = 0, double t = 0, double h = 0)
	{
		name = n;
		first = f;
		second = s;
		third = t;
		fourth = h;
	}

	void showinfo(CorpData part)
	{
		cout << "Branch: " << part.name << endl;
		cout << "Total Sales   : " << part.total << endl;
		cout << "Average Sales : " << part.avg << endl;

	}
	void calculate(CorpData calc)
	{
		calc.total = calc.first + calc.second + calc.third + calc.fourth;
		calc.avg = (calc.total) / 4;
	}
};

void showinfo(CorpData);
void calculate(CorpData);

int main()
{
	CorpData data1("East", 10000, 80000, 20000, 30000);
	CorpData data2("West", 20000, 70000, 10000, 40000);
	CorpData data3("North", 30000, 60000, 20000, 30000);
	CorpData data4("South", 40000, 50000, 10000, 40000);

	const int Branch = 4;

	CorpData data[Branch] = { data1, data2, data3, data4 };

	for (int i = 0; i < Branch; i++)
	{
		calculate(CorpData);
		showinfo(CorpData);
	}

	return 0;
}
CorpData is a type. You can't pass types to function in the argument list. calculate and showinfo expects a CorpData object to be passed in.
Topic archived. No new replies allowed.