Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一些代码需要将向量的第一个和最后一个元素分配为特殊情况。
somevector.back() 是左值吗?下面的代码会起作用吗?
some_vector.front()=first_value; some_vector.back()=last_value;
是的,它可以,因为它返回对最后一个元素的引用。最好先确保它不是空的!