注册 登录
编程论坛 C++教室

【请教】C++中引用运用于结构,这个代码中定义的第三个函数怎么解释??

bxxue 发布于 2013-10-05 21:10, 480 次点击
#include <iostream>
#include <string>
using namespace std;
struct free_throws
{
    string name;
    int made;
    int attempts;
    float percent;
};
void display (const free_throws & ft);
void set_pc (free_throws & ft);
free_throws & accumulate (free_throws & target,const free_throws & source);
请问  声明free_throws & accumulate (free_throws & target,const free_throws & source);这个函数时,free_throws & 中&在这的作用是什么,是代表返回值是引用么?我不用&似乎也可以???
1 回复
#2
blueskiner2013-10-06 11:11
什么叫引用?就是变量的地址。不用引用的函数返回类或结构,就是返回一个拷贝。
1