error: pointer to object type

i am getting a pointer to object error on the following code. I am new to programming and don't understand the error. Can someone please point out the issue and explain why the issue is there? please note i am at the beginning of writing this program.

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
 #include <iostream>
#include <iomanip>
#include <string>

using namespace std;

const int COLS = 6;
const int ROWS = 5;
double getTotal(int[][COLS]);
double getAverage(int[][COLS]);
double getRowTotal(int[][COLS], int);
double getColumnTotal(int[][COLS], int);
double getHighest(int[][COLS], int&, int&);
double getLowest(int[][COLS], int&, int&);

int main()
{
	
	string division[ROWS] = { "North", "South", "East", "West", "Quarter Total" };
	string quarter[COLS] = {"", "Quarter 1", "Quarter 2", "Quarter 3", "Quarter 4", "Division Total"};
	
	int count, div, qtr;
	int sales;

	for (div = 0; div < ROWS; div++)
	{
		for (qtr = 0; qtr < COLS; qtr++)
		{
			

			cout << "What is the sales amount for " << division[ROWS] << "division, "
				<< quarter[COLS] << "?" << endl;
			cin >> sales[div][qtr];
		}
		while (sales[div][qtr] < 0)
		{
			cout << "You entered an invalid number please enter a value greater than 0." << endl;
			cin >> sales[div][qtr];
		}
	}

	return 0;
}
closed account (48T7M4Gy)
line 35 refers to a 2 dimensional integer array, when in fact sales[div][qtr] is an integer.
1
2
3
cout << "What is the sales amount for " << division[ROWS] << "division, "
				<< quarter[COLS] << "?" << endl;
			cin >> sales[div][qtr];


shouldn't this be:

1
2
3
cout << "What is the sales amount for " << division[div] << "division, "
				<< quarter[q] << "?" << endl;
			cin >> sales;


Keeping in mind you probably, by the look of it, need to define a sales array.
i.e int sales[ blah blah][blah blah] etc
Last edited on
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
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

const int COLS = 6;
const int ROWS = 5;
double getTotal(int[][COLS]);
double getAverage(int[][COLS]);
double getRowTotal(int[][COLS], int);
double getColumnTotal(int[][COLS], int);
double getHighest(int[][COLS], int&, int&);
double getLowest(int[][COLS], int&, int&);

int main()
{

	string division[ROWS] = { "North", "South", "East", "West", "Quarter Total" };
	string quarter[COLS] = { "", "Quarter 1", "Quarter 2", "Quarter 3", "Quarter 4", "Division Total" };

	int count;
	int div;
	int qtr;
	int sales[ROWS][COLS];

	div = 0;
	qtr = 0;
	for (; div < ROWS; div++)
	{
		for (; qtr < COLS; qtr++)
		{


			cout << "What is the sales amount for " << division[div] << "division, "
				<< quarter[qtr] << "?" << endl;
			cin >> sales[div][qtr];
		}
		while (sales[div][qtr] < 0)
		{
			cout << "You entered an invalid number please enter a value greater than 0." << endl;
			cin >> sales[div][qtr];
		}
	}

	return 0;
}
closed account (48T7M4Gy)
int sales ... makes more sense ;)
Thanks everyone, I think i understand what needs to happen now when i see that error again. I really appreciate the assistance on this site. You are all awesome!!
Topic archived. No new replies allowed.