Compiler Error C2106 when trying to simulate a vector

I'm trying to write a fake vector for my class assignment, and I currently get an error in the member function pushBack.
The compiler doesn't seem to like incrementing the SIZE variable which holds the number of elements in the "vector". Is there something I might need to fix?
Your assistance would be highly appreciated for helping me with this, and any other problems you might happen to find.

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
/*
Write a simple program that simulates the behavior of vectors
-You should be able to add and remove elements to the vector
-You should be able to access an element directly.
-The vector should be able to hold any data type.
*/


#include <stdio.h>

template <class T, int SIZE>
class Vector
{
	#pragma region constructors&destructors
	private:
	T vec[SIZE];
	
	public:

	Vector()
	{}
	~Vector()
	{}
	#pragma endregion

	template <class T/*, int SIZE*/>
	void defineVec(T var)
	{
		for(int i=0; i<SIZE; i++)
		{
			vec[i] = var;
		}
		//printf("All elements of the vector have been defined with %", var)
		//What should I do when trying to print a data type or variable 
                //of an unspecified one along with the '%'?
	}
	
	template <class T/*, int SIZE*/>
	void pushBack(T var)
	{
		SIZE ++; //C1205
		vec[SIZE - 1] = var;
	}
	
	template <class T/*, int SIZE*/>
	void popBack()
	{
		vec[SIZE - 1] = NULL;
		SIZE--;
	}
	
	//template <class T/*, int SIZE*/>
	void showElements()
	{
		for(int i=0; i<SIZE; i++)
		{
			printf("%d",vec[i]);
			printf("\n");
		}
	}
};

int main()
{
	Vector <int, 5> myints;
	myints.pushBack(6);
	myints.showElements();
	return 0;
}
I am still a beginner but i think pushback is supposed push_back()
and i think the site that you want to look over is:
http://www.cplusplus.com/reference/stl/vector/push_back/

I hope that helps.

- hirokachi
@Hirokachi, it is push_back(); in the STL. He's trying to replicate it in his own code, so it's not the same thing.
SIZE is like a macro because of how it is a template parameter. EG if you passed 32 for the size, it'd be like doing 32--; or 32++;
@ thumper Oh okay, Thanks Thumper. I don't know what i was thinking. I guess I was just in a hurry. Thanks again for the correction.
Topic archived. No new replies allowed.