| | |
does anyone know what this means?
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
That means you are literally treating something that isn't an lValue as an lValue.
For example if a method doesn't return a reference to something, its possible that attempting to treat the method as an lvalue wont work since you're returning a copy of the actual object in which that copy may not be assigned to anything else...
It's actually hard for me to believe that you can't treat a temporary as an lValue considering potential chained = statements.
I believe this is an appropriate example--
( please excuse the code inlining - I'm in a hurry @_@ )
Edit: Actually its possible that primitive types, which aren't objects, will be the most likely to flag such an error. It's possible that the assignment operator isn't valid for 'const' or temporary types (which makes sense, otherwise you could change the value of the number 9 by assigning it 5 and get the value of 5 instead of 9 wen you need 9... that would be a pain @_@ )
-Alex
For example if a method doesn't return a reference to something, its possible that attempting to treat the method as an lvalue wont work since you're returning a copy of the actual object in which that copy may not be assigned to anything else...
It's actually hard for me to believe that you can't treat a temporary as an lValue considering potential chained = statements.
I believe this is an appropriate example--
( please excuse the code inlining - I'm in a hurry @_@ )
c++ Syntax (Toggle Plain Text)
int method(){ return 9; } int& method2(int num){ return num; } int main(){ method() = 8; // should throw an error int x = 10; method2(x) = 5; // valid since the method returns a reference which can be assigned a value }
Edit: Actually its possible that primitive types, which aren't objects, will be the most likely to flag such an error. It's possible that the assignment operator isn't valid for 'const' or temporary types (which makes sense, otherwise you could change the value of the number 9 by assigning it 5 and get the value of 5 instead of 9 wen you need 9... that would be a pain @_@ )
-Alex
Last edited by Alex Edwards; Nov 20th, 2008 at 7:21 pm.
![]() |
Similar Threads
- Genetic K-means Algorithm (VB.NET)
- what it means ? (C++)
- virtual void drive() = 0 What this means? (C++)
- does anyone know what this means (C++)
- Vista Crack Means Big Trouble (Windows Vista and Windows 7)
- Do you have any idea what this means? (C)
- What means "best practice"? (Java)
- K-means clustering (Python)
- Would someone please explain what folding means? (Geeks' Lounge)
Other Threads in the C++ Forum
| Thread Tools | Search this Thread |
api application array arrays based beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion convert count data database delete desktop developer directshow dll dynamiccharacterarray email encryption error file forms fstream function functions game generator getline graph homeworkhelper iamthwee ifstream input int integer java lib linux list loop looping loops map math matrix memory multiple newbie news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates text tree url vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets





