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

c++ 返回值是引用或者非引用

2014-02-07 09:40 197 查看
//============================================================================

// Name : TestReference.cpp

// Author :

// Version :

// Copyright : copy rigt

// Description : Hello World in C++, Ansi-style

//============================================================================

#include <iostream>

#include "Object.h"

using namespace std;

int main() {

cout << "!!!Hello World!!!" << endl;

Object o;

/* 0x22fe20

0x22fe10

0x22fe30*/

Object o1=o.retrunObject();

const Object &o2=o.retrunObject();

cout<<&o<<endl;

cout<<&o1<<endl;

cout<<&o2<<endl;

/* 0x22fe10

0x22fdf0

0x22fe10*/

Object o11=o.retrunReference();

Object &o22=o.retrunReference();

cout<<&o<<endl;

cout<<&o11<<endl;

cout<<&o22<<endl;

return 0;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: