tag:blogger.com,1999:blog-5291685016268759147.post994269948191957610..comments2023-06-13T01:25:58.549-07:00Comments on how2java forum: why the reference of temporary object is valid here?javatubehttp://www.blogger.com/profile/15526548399393457583noreply@blogger.comBlogger1125tag:blogger.com,1999:blog-5291685016268759147.post-25492910345126905392012-04-12T23:15:42.298-07:002012-04-12T23:15:42.298-07:00Temporary objects last until the end of the full-e...Temporary objects last until the end of the full-expression in which they are created - roughly speaking, until the ; at the end of the line. References to them are valid until that point.<br /><br />However, it's not valid to bind it to a non-const reference as you do. The only reason that compiles is because your compiler is over 15 years old, and the language has been through two major changes since then. I suggest you upgrade to one of this millenium's compilers.javatubehttps://www.blogger.com/profile/15526548399393457583noreply@blogger.com