有人可以幫助我理解爲什麼下面的代碼將導致警告 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