stl - Assign a C++ out reference to something that was destroyed? -


So I'm looking at some code, and I see it:

  class which Also {public: some faxes (some class and outgoing) {outVal = m_q.front (); M_q.pop (); } Private: std :: queue & lt; SomeClass & gt; M_q; };  

It would not seem like an outval would be a valid reference and more ... However, it appears to work

I have already done it in other code Have seen, is this valid? Thanks

Remember that the references are not like pointers: they rebound They can not be created after they mean that if I

  int a; Int b; Int and C = A;  

Then within that radius, an assignment to c actually means an assignment. Therefore,

  int a = 2; {Int b = 3; Int and C = A; C = B; B = -5; } Printf ("% d", a); // print "3"  

Therefore, in this case, reference is not being marked on the object being removed . Instead, the return value of m_q.front () is copied , whatever the external reference, through the assignment operator.


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -