Binding temporary to const reference in c'tor initializer list
问题 Section 12.2.5 in C++03 says " A temporary bound to a reference member in a constructor’s ctor-initializer (12.6.2) persists until the constructor exits " So I tried following program #include<iostream> using namespace std; struct foo { foo() { cout<<"foo c'tor"<<endl; } ~foo() { cout<<"foo d'tor"<<endl; } }; struct bar { const foo &ref; bar():ref(foo()) { cout<<"bar c'tor"<<endl; } }; int main() { bar obj; } The output I get is : foo c'tor foo d'tor bar c'tor Now according to standard,