Operator overloading, wierd behaviour

Greetings!

I’ve just started porting my application to use classes, and I’ve ran into a wierd error, and I have no clue how to resolve this:

This is the test operator within the class:

__device__ T& operator[](int idx){

		if(idx<size)

			return  data[indx*size+idx];

	}

but, when I try to use it:

p[0]=d_x[tid]; (p is an instance of the class, d_x is an array)

but it dies with an error saying

no operator "=" matches these operands

              operand types are: pelda<int> = int

I dont understand why is this happening, the operator should return with a reference to an int value, so the equation should be valid, pls help!

Thanks in advance!

Okay realized my error, it should be (*p)[0]