是否可以传递函数对map元素的值的引用,并在那里修改它?
foo(string & s) { s = "xyz"; } map m; m[1] = "abc"; foo(m[1]); // <-- Is it ok? Will m[1] be "xyz" after this call?
谢谢.
答案是肯定的.
(operator []返回一个引用)