954,492 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

non-lvalue in assignment

I have a matrix class which there are matrix objects. I want to call .value(int,int) directly on the matrix objects and set the internal 2d vector to the value on the right side of the equal sign.

Here is what I want to do:

[code]
new_matrix.value(row,col) = 0;
[code]

Here is what I've tried:

int &Matrix::value(int row, int col)
{
    return this->mat[row][col];
}


Where mat is the internal 2d vector data.

server_crash
Postaholic
2,111 posts since Jun 2004
Reputation Points: 113
Solved Threads: 20
 

I don't find any problem in the code

SpS
Posting Pro
599 posts since Aug 2005
Reputation Points: 70
Solved Threads: 32
 

That's what someone else said. Which compiler are you using? I'm using bloodshed.

server_crash
Postaholic
2,111 posts since Jun 2004
Reputation Points: 113
Solved Threads: 20
 

It should work in both dev and VC...anyworks from next time give your complete code

SpS
Posting Pro
599 posts since Aug 2005
Reputation Points: 70
Solved Threads: 32
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You