Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!paperboy!hsdndev!husc6!ngo From: ngo@tammy.harvard.edu (Tom Ngo) Newsgroups: comp.lang.c++ Subject: What is the cv-qualifier of a reference? Message-ID: Date: 2 Apr 91 20:35:25 GMT Sender: news@husc6.harvard.edu Distribution: comp Organization: Harvard Chemistry Department Lines: 79 On March 25 I posted a question to which nobody replied. Here it is again, in shorter form: [What I do understand] A pointer can have a cv-qualifier, e.g. int *const p; here the cv-qualifier is "const" and it refers to the pointer, NOT to the object pointed to. [What I don't understand] A reference can have a cv-qualifier, e.g. int &const j; What does const mean in this case? What restrictions are placed on j? My original post, which I feel was more precisely worded, is included below. =========================================================================== (Message unread:29) Return-Path: ngo@tammy.harvard.edu From: ngo@tammy.harvard.edu (Tom Ngo) Newsgroups: comp.lang.c++ Subject: What? A reference can have cv-qualifiers? Date: 25 Mar 91 15:13:59 GMT Distribution: comp Organization: Harvard Chemistry Department I'm confused. I just read in ARM 8.2.2 [References]: In a declaration T D where D has the form & cv-qualifier-list-opt D1 the type of the contained identifier is "... cv-qualifier-list reference to T." I cannot imagine what the cv-qualifiers do! In the case of a pointer, we read ARM 8.2.1 [Pointers]: In a declaration T D where D has the form * cv-qualifer-list-opt D1 the type of the contained identifier is "... cv-qualifer-list pointer to T." The cv-qualifiers apply to the pointer and not to the object pointed to. and of course that makes total sense. But how could cv-qualifiers apply to a reference? const int& i; // reference to const int int &const j; // const reference to int? What restrictions are there on j? We already know that j cannot be made to refer to a different object since in ARM 8.4.3 [References] we have A variable declared to be a T& ... must be initialized .... A reference cannot be changed to refer to another object after initialization. I would appreciate responses by email, and I will summarize. No doubt I will be flooded by replies that say "No, no, you are totally misunderstanding references!" Thanks in advance... -- Tom Ngo ngo@harvard.harvard.edu 617/495-1768 lab number, leave message -- Tom Ngo ngo@harvard.harvard.edu 617/495-1768 lab number, leave message