#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();
它们属于哪里,是另一个类的构造函数,还是调用变量的另一种方式,我一直在努力找出几个小时
感谢您的帮助
这是基本的C ++语言,因此您可能希望掌握一些知识。
它们是返回对Point
的引用的成员函数(或方法,如果您更喜欢该术语)。如果将返回类型Point &
替换为例如int
,则语法应该看起来很熟悉。另外,您确实需要回过头来学习基础知识。