+// Example 1
string f() { return "abc"; }
void g() {
const string& s = f();
cout << s << endl; // can we still use the “temporary” object?
}
string f() { return “abc”; }
void g() {
string& s = f(); // still legal?
cout << s << endl;
}
두 코드의 차이 ?? const라는 녀석이 있군요. const reference의 Life Time에 대해서 잘 알고 계신가요 ??
간만에 들어간 Herb Sutter의 Blog에 반가운 GOTW가 올라와 있더군요
http://herbsutter.wordpress.com/2008/01/01/gotw-88-a-candidate-for-the-most-important-const/



0 Responses to “[blogging] Reference Life Time”