"not an lvalue"

CrypticMetaphor CrypticMetaphor88 at gmail.com
Sun May 1 06:30:34 PDT 2011


Hi, I've been away from D for a while, but now I'm back and I'm stuck 
with an compile time error.

I've got a Matrix33 class and a Vector3 class, but something is wrong 
with the way I return my Vector3 in my matrix class:

If I do this I get an error:

Matrix33 mtest = new Matrix33();
mtest.SetIdentity();
Vector3 test1 = new Vector3(0, 0, 0);
Vector3 test2 = test + mtest.GetColumn(2);

I get the error "Error: mtest.GetColumn(x) is not an lvalue"

But the following works:

Matrix33 mtest = new Matrix33();
mtest.SetIdentity();
Vector3 test1 = new Vector3(0, 0, 0);
Vector3 temp = mtest.GetColumn(2);
Vector3 test2 = test + temp;

// GetColumn method
Matrix33
{
// ...

   /// Get a matrix column, horizontal line
   Vector3 GetColumn(uint index)
   {
     assert(!(index > 2), "index is too high");
     return new Vector3(cell[index * 3], cell[index * 3 + 1], cell[index 
* 3 + 2]);
   }
// ...
}

My questions:
What changes do I have to make to make the first example compile?


More information about the Digitalmars-d-learn mailing list