473,324 Members | 2,313 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Reference are always lvalue?

200 100+
Hello everyone,


Is the conclusion correct? Both const reference and non-const reference are lvalue?

I think it is true and I can not find a sample which does not follow it.


thanks in advance,
George
Dec 21 '07 #1
6 1352
weaknessforcats
9,208 Expert Mod 8TB
An lvalue means you can use the object on the left of an assignment operator.

A const reference refers to an object that can't be changed.

Therefore, a const reference can't be used as an lvalue.

That's not to say that the const reference can't be use on the left of any operator, just those that would change the object.
Dec 21 '07 #2
George2
200 100+
Sorry weaknessforcats,


I do not agree that lvalue is something that could be on the left side of an assignment operator, but something adressable.

An lvalue means you can use the object on the left of an assignment operator.

regards,
George
Dec 22 '07 #3
weaknessforcats
9,208 Expert Mod 8TB
I do not agree that lvalue is something that could be on the left side of an assignment operator, but something adressable.
Read The ANS-C Progrmaming Language by Kernighan & Ritchie page 197 Section A5.
Dec 22 '07 #4
George2
200 100+
Sorry weaknessforcats, I do not have that book at hand. Do you know where can I find related statements you quoted from the book from internet? :-)

If can not find, it is appreciated if you could post here if the statements are not too long.

BTW: seems you are talking about lvalue and rvalue in the context of C, but I am talking about lvalue and rvalue in the context of C++.

Read The ANS-C Progrmaming Language by Kernighan & Ritchie page 197 Section A5.

regards,
George
Dec 24 '07 #5
weaknessforcats
9,208 Expert Mod 8TB
BTW: seems you are talking about lvalue and rvalue in the context of C, but I am talking about lvalue and rvalue in the context of C++.
Same meaning in both languages.

Surely you have The C++ Programming Language by Bjarne Stroustrup 3rd Edition?? Look at section 4.9.6.

This is less authoritative: http://www.cs.ucsc.edu/~pohl/code/lvalue.htm.
Dec 24 '07 #6
George2
200 100+
Thanks weaknessforcats,


Let us come back to the conclusion. You think,

1. const reference is rvalue;
2. non-const reference is lvalue?

Right?

Same meaning in both languages.

Surely you have The C++ Programming Language by Bjarne Stroustrup 3rd Edition?? Look at section 4.9.6.

This is less authoritative: http://www.cs.ucsc.edu/~pohl/code/lvalue.htm.

regards,
George
Dec 25 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

110
by: Mr A | last post by:
Hi! I've been thinking about passing parameteras using references instead of pointers in order to emphasize that the parameter must be an object. Exemple: void func(Objec& object); //object...
6
by: wizwx | last post by:
Is there anything wrong with the following code? class A { ... }; class B : public A { ... }; // definitions of class A and B, these are OK Foo() { A & a = B(); // ?? A * p = &B(); // ??...
10
by: JurgenvonOerthel | last post by:
Consider the classes Base, Derived1 and Derived2. Both Derived1 and Derived2 derive publicly from Base. Given a 'const Base &input' I want to initialize a 'const Derived1 &output'. If the...
41
by: Summercool | last post by:
Can we confirm the following? also someone said, Java also has "reference" like in C++, which is an "implicit pointer": Pointer and Reference --------------------- I am starting to see what...
3
by: George2 | last post by:
Hello everyone, I am debugging MSDN code from, http://msdn2.microsoft.com/en-us/library/0eestyah(VS.80).aspx here is my output, 1>main.cpp
5
by: George2 | last post by:
Hello everyone, This is my understanding of non-const reference, const reference and their relationships with lvalue/rvalue. Please help to review whether it is correct and feel free to...
1
by: George2 | last post by:
Hello everyone, Is the conclusion correct? Both const reference and non-const reference are lvalue? I think it is true and I can not find a sample which does not follow it.
13
by: asm23 | last post by:
Hi,I need some help to clarify the warning "initial value of reference to non-const must be an lvalue". I'm searching in this groups to find someone has the same situation like me. I found in...
22
by: Ruben | last post by:
Why would a method that is defined to return a reference such as with the operator overload of , operator, href& operator(int index){ return _array; } not cause a type mismatch compiler...
275
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.