i am currently thinking about the following problem and cant find any more goolge helps:
i need to demonstrate that functions returning primitive types return rvalues and functions returning objects return lvalues. easy enough with an int and a string object. the part i am stuck on is: how can i change the lvalue i get from a function, say a string, to a rvalue. already in the return type. such that something like the stupid code:
lvalFunc() = "Hello World\n";
does not compile anymore. i can clearly change the return type to a const, but that simply prevents the returned string from being changed and does not make it an lvalue, right?!
I d be greatful for any ideas (:
any other operators that i can use on strings that require an lvalue?
It's tricky because lvalue-to-rvalue conversion is implicit, so if an operator accepts rvalue arguments, it will accept lvalue arguments as well. With sufficient C++11 support, you could write a little tester class, but I can't think of another operator.
Last edited on
Topic archived. No new replies allowed.
You are using a version without Ads of this website. Please, consider donating: