有人可以帮助我理解为什么下面的代码将导致警告 struct A
{
A() : _a(0) {}
const int& _a;
};
int main()
{
A a;
}
与警告 warning: binding reference member '_a' to a temporary value [-Wdangling-field]
#include <sstream>
#include <string>
using namespace std;
template<typename T>
string ToString(const T& obj)
{
ostringstream oss;
oss << obj;
//
// oss will never be used a