Thread: Lvalue required --compile error--

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    3

    Lvalue required --compile error--

    my source code is that:

    Code:
    class Matrixes
    {
    
    long double **data;
    
    public :
    
    Matrixes(int row,int column);
    ~Matrixes();
    
    long double** Matrixes::get();
    
    };
    
    
    
    Matrixes::Matrixes(int row,int column)
    {
    data = new long double*[row];
    for (int j = 0; j < row; j++)
    data[j] = new long double[column];
    }
    
    Matrixes::~Matrixes()
    {
    }
    
    long double** Matrixes::get()
    {
    return(data);
    }
    
    
    
    
    class Operations
    {
    public:
    
    long double** accumulate(long double **dataC,long double **dataA,long double **dataB,int row,int column)
    {
    Matrixes m1(3,4); // dimension of m1 object memory allocation
    m1.get()=dataA; // (1) ---------COMPILE ERROR---------
    .
    .
    .// function code
    .
    
    return(dataC);
    }
    
    
    };
    in (1) line i have came across "Lvalue required"
    what does it means?
    what can i solve this problem

  2. #2
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,273
    You trying to dynamically allocate a 2D Array? try this:

    Code:
    	char **X = new char*[cols];
    	*X = new char [rows];
    
    	for	( int i=0; i<rows; i++ )
    	{
    		for ( int j=0; j<cols; j++ )
    		{
    			X[i][j] = '*';
    			cout<< ends << X[i][j];
    		}
    		cout<< endl;
    	}
    but just change the chars to doubles. Cols and Rows are parameters the user has inputted.
    Last edited by twomers; 05-19-2006 at 07:12 AM. Reason: Forgot to explaing things

  3. #3
    ... arjunajay's Avatar
    Join Date
    May 2005
    Posts
    203
    A function cannot be put on the left hand side of an '=' expression unless it returns a 'reference'. ???
    eg:
    Code:
    int& max(int &a, int &b){  //this function can be put as it returns 'int &'
       return (a>b)? a : b;
    }
    PS: this is just a quick code... I have NOT tested it...

    LVALUE is just a fancy name for things that can be put on the left hand side.
    temporary objects like the double** you returned are NOT lvalue ???
    Last edited by arjunajay; 05-19-2006 at 07:42 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beginner Needs help in Dev-C++
    By Korrupt Lawz in forum C++ Programming
    Replies: 20
    Last Post: 09-28-2010, 01:17 AM
  2. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  3. Errors including <windows.h>
    By jw232 in forum Windows Programming
    Replies: 4
    Last Post: 07-29-2008, 01:29 PM
  4. failure to import external C libraries in C++ project
    By nocturna_gr in forum C++ Programming
    Replies: 3
    Last Post: 12-02-2007, 03:49 PM
  5. file reading
    By gunghomiller in forum C++ Programming
    Replies: 9
    Last Post: 08-07-2007, 10:55 PM