-3
我真的很新的C++和我有一个非常简单的问题,C++类和对象
struct triplet {
int first;
int second;
int third;
};
class mystery {
private:
int x;
int y;
struct triplet* the_triplet;
public:
mystery(int f, int s, int t);
~mystery();
mystery & mystery_member(const mystery & other) const;
};
什么行
mystery & mystery_member(const mystery & other) const;
意味着或做?
它在mystery上声明一个const非静态成员函数,它需要一个'mystery const&'并返回一个'mystery&'。 – rightfold
那么&其他代表的究竟是什么? – Andy
@Andy'&'表示引用作为参数传递而不是副本。 'other'是为了可读性。它应该暗示参数在函数中扮演什么角色。在函数的删除中不需要它。在函数的实现中,它是可以用来访问函数体内参数的变量。 – Oswald