C++ 易错提醒 发表于 2021-08-11 分类于 C和CPP 不要返回局部对象的引用 12345std::string & func(){ std::string temp = "hello"; return temp; // Wrong!} 可以返回类对象成员的引用,因为在对象存续期间,该成员也是存在的。 引用其实是指针的语法糖