您的位置:首页 > 编程语言 > C语言/C++

c++学习笔记之函数引用返回

2014-09-22 00:00 513 查看
#include<iostream>
using namespace std;
#include<string>
#include<map>
#include<vector>
#include<time.h>
#include <stdlib.h>
#include <stdio.h>
#include <algorithm>
string& test()
{
string s("hello");
return s;
}
int main()
{
string ns;
ns=test();
system("pause");
}
局部变量在运行完毕后 ,会被编译器释放掉,所以,这种函数不合法。
c++中引用和指针的反汇编是一样的
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: