【发布时间】:2020-04-04 20:04:32
【问题描述】:
#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();
它们属于哪里,是另一个类构造函数还是调用变量的另一种方式, 我已经想了好几个小时了
感谢您的帮助
【问题讨论】:
-
函数返回对
Point的引用 -
以下划线后跟大写字母的标识符、带有双下划线的标识符以及在全局范围内以下划线开头的标识符是保留的,因此使用它们是未定义的行为。你应该改变
_RECT。
标签: c++ visual-c++ methods func datamember