C++ reference changes when push_back new element to std::vector
问题 I am not sure what to make of this - please tell me what's wrong with the code below. I modified my code to reduce it to the simplest terms. There is a std::vector with a bunch of MyNode objects. The first step is to get a constant reference to one of the data elements of one of these nodes (Data m_data) - in the example below, there is only one node before the 2nd node is inserted as seen below: const cv::Data& currData = m_nodesVector[currIndex].GetData(); MyNode node(...); m_nodesVector