Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!ucsd!swrinde!cs.utexas.edu!uunet!microsoft!jimad From: jimad@microsoft.UUCP (Jim Adcock) Newsgroups: comp.lang.c++ Subject: Re: Modifying References Message-ID: <9193@microsoft.UUCP> Date: 28 Nov 89 18:17:41 GMT References: <4280@cadillac.CAD.MCC.COM> Reply-To: jimad@microsoft.UUCP (Jim Adcock) Distribution: na Organization: Microsoft Corp., Redmond WA Lines: 32 // At least present compilers don't strictly enforce this restriction -- // my 1.2 compatible version accepts the following. It would be nice to // know what the real restrictions really are, and why. Presumably, // eventually, it will be possible to make C++ compilers that // generate more efficient code based on the knowledge that references // "don't change." A reference is not the same thing as an automatically // dereference pointer -- that just happens to be the way that cfront // implements them. Anybody know what the "real rules" are in using // references? Is the below legal, or just not yet enforced by compilers? #include typedef char* strng; strng v[] = { "hi mom", "hi dad", "hi bro", "hi sis", 0 }; main() { strng* p = v; while (*p != 0) { strng& str = *p; printf("%s\n",str); ++p; } }