invalid initialization of non-const reference

I am trying to reference to a class variable which is a vector<int> and change value of the vector. I got this error. what am I doing wrong? thanks in advance. ( "pick" is just an int. )
1
2
3
4
5
6
7
8
9
10
11
12
13
void WLD(int &player)
	{	
		vector<int> &temp=vector<int>();
		if (player==1)
			temp=this->value1();
		else
			temp=this->value2();
		temp[pick-1]=value[pick-1];	
		if (sum15(temp))
		{
			cout<<"WINS!"<<endl;
		}
	}

Last edited on
This looks strange. What you are doing on lines 5 and 7 is certainly illegal; you cannot "re-seat" a reference. Why not just pas the vector itself in addition to the player number?
oh i see. I just want to simply my part of my codes with those codes. how can I do it? besides pass the vector? thanks
Topic archived. No new replies allowed.