Thread: error C2105: '++' needs l-value

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    1

    error C2105: '++' needs l-value

    Hi, I've problem with compile this code (using VC++ 2010). I've got an error
    "error C2105: '++' needs l-value" ... on penultimate row but I can't figurate, what's the problem.

    Code:
    int Push(double value)
    {
    	if(stack == NULL)
    		return 1;
    	if(position+sizeof(double) > stack+size)
    		return 1;
    	*(double*)position = value;
    	((double*)position)++;              // ON THIS LINE I GET ERROR                        
    	return 0;
    }

  2. #2
    -bleh-
    Join Date
    Aug 2010
    Location
    somewhere in this universe
    Posts
    463
    Position has never been declared or passed into that function unless it's global. You can't just cast anything to a pointer and use pointer arithmetic.
    "All that we see or seem
    Is but a dream within a dream." - Poe

Popular pages Recent additions subscribe to a feed