visual c++ - Reference to reference is not allowed in ISO C++ 2003 standard, but why it is allowed by compilers? -


According to ISO C ++ 2003 Standard Section 8.3.2

"References "

But I have tried to do the following code in Visual C ++ and Iododon, and both compilers are running this code successfully.

  int main () {int i = 2; Int and Rif_I = I; Int. & Amp; Ref_ref_i = ref_i; There should be an error according to the // C ++ 2003 Standard Cot; & Lt; I & lt; & Lt; Andal & lt; & Lt; Ref_i & lt; & Lt; Andal & lt; & Lt; Ref_ref_i; Return 0; }  

I am really confused by seeing this behavior of the compiler; Can anyone explain this?

You do not make reference-to-context in your code.

This is just another int and , i.e. both an int

(an invalid C ++ 03 reference of TC For reference)


C ++ 11 Standard section § 8.3.2 clearly shows with an example (References to reject contexts, of course, C ++ 03 and C +11, but the reference mold is new in C ++ 11):

If a typed name (7.1.3, 14.1) or a deltopepe-specifier (7.1.6.2) A type of T that is a reference to type T, "Sieve In an effort to make Lavlu reference "type TR makes" the Lavlu reference "to type, while making an effort to kind of make Revlu reference" in terms of "Arviaar the TR.

  int i; Typingface int & amp; LRI; Typingface int & amp; RRI; LRI & amp; R1 = I; // R1 has type int and ambition; Const LRI & amp; R2 = I // R2 has a type int and ambition; Const LRI & amp; R3 = I // R3 Type at & amp; amp;  

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -