草庐IT

allemployees

全部标签

c++ - STD 馆藏中引用文献的生命周期

对STD集合返回的元素(例如map)的引用有效多长时间?例如,在这段代码中:structEmployee{intsalary;stringname;//thekey};mapallemployees;...Employee&Joe=allemployees["JoeSmith"];Joe.salary=150;//change"JoeSmith"'ssalaryassert(allemployees["JoeSmith"].salary==150);//alwaystrue....allemployees["MarkJones"]=Employee();...//No"JoeSmith