Mysterious C2228 and C2227 errors VC++

closed account (yCf9216C)
The intellisense keeps telling me that on the lines "MyVector.size()" "Expression must have a class type". I don't know why, the vector has been successfully passed to the function, and I've typed EVERYTHING correctly. Its not finished, and some of it may not make sense to any of you.

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
#include<iostream>
#include<vector>
#include<time.h>
using namespace std;

void stats (vector<int> MyVector ()) {
	vector <int> MyTallyVector (10);
	for (int counter = 0; counter < MyVector.size(); counter += 1 ) { 
		int VectorContainer =  MyVector.at(counter); 
	switch (VectorContainer) {
	case 2:
		MyTallyVector.at(0) += 1; 
		break;
	case 3:
		MyTallyVector.at(1) += 1;
		break;
	case 4:
		MyTallyVector.at(2) += 1; 
		break;
	case 5:
		MyTallyVector.at(3) += 1;
		break;
	case 6:
		MyTallyVector.at(4) += 1; 
		break;
	case 7:
		MyTallyVector.at(5) += 1;
		break;
	case 8:
		MyTallyVector.at(6) += 1; 
		break;
	case 9:
		MyTallyVector.at(7) += 1;
	 	break;
        case 10:
		MyTallyVector.at(8) += 1; 
		break;
	case 11:
		MyTallyVector.at(9) += 1;
		break;
	case 12:
		MyTallyVector.at(10) += 1; 
		break;

			default:
			cout << "The VectorContainer did not match any range value.\n";
			break;
	}
	for (int count = 0; count < MyTallyVector.size(); count += 1) {
		int MaxSum = 0;
		int StoreThisOne = 0;
		if (MyTallyVector.at(count) > MaxSum) { 
			MaxSum = MyTallyVector.at(count);
			StoreThisOne = 0; 
			TieBool = false;
		}
		else if (MyTallyVector.at(count) == MaxSum ) { 
			TieBool = true;
			StoreThisOne = MaxSum; 
		}
}

int main () {
	vector <int> MyVector (6);
	MyVector.at(0) = 3;
	MyVector.at(1) = 3;
	MyVector.at(2) = 5;
	MyVector.at(3) = 9;
	MyVector.at(4) = 9;
	MyVector.at(5) = 9;

	stats (MyVector() );
	cin >> MyVector.begin();
	return 0;
}


The Main() function simply assigns test values to the vector, then passes it to the function. The function will find the most common roll. It does this by passing through the vector, comparing each container with a range of values. If a value is found, the spot it corresponds to in the MyTallyVector is incremented by one. The biggest problem is the STUPID INTELLISENSE!! I've tried EVERYTHING!!
On line 6 you should remove the ().
There is two ending brackets } missing in the stats function.
On line 72 you should also remove the ().
Line 73 will not work. MyVector.begin() returns an iterator and you can use >> on an iterator.
Topic archived. No new replies allowed.