[英]What the function's signature means?
#ifndef _RECT
#define _RECT
#include "Point.h"
using namespace std;
class Rectangle
{
private:
Point _topLeft;
Point _bottomRight;
int _color;
public:
Rectangle( double left, double top, double width, double height, int color );
~Rectangle() { --m_count; };
public:
int getColor() const;
Point& getTopLeftPoint();
Point& getBottomRightPoint();
void setColor( int color );
public:
bool contains( const Point &p );
void moveRect( double deltaLeft, double deltaTop );
void scaleRect( double rectWidth, double rectHeight );
void setBigger(int x, int y) const;
public:
static int m_count;
};
#endif
我不明白签名的含义:
Point& getTopLeftPoint();
Point& getBottomRightPoint();
它们属于哪里,是另一个 class 构造函数还是调用变量的另一种方式,我一直在试图弄清楚几个小时
谢谢您的帮助
这是基本的 C++ 语言,所以你可能想复习一下你的知识。
它们是返回对Point
的引用的成员函数(或方法,如果您更喜欢该术语)。 如果将返回类型Point &
替换为例如int
,则语法应该看起来很熟悉。 否则,您确实需要返回 go 并学习基础知识。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.