我有以下类:我的功能链不想工作,为什么?
GLRectangle.h
#include "XPView.h"
class GLRectangle
{
public:
int top, left, bottom, right;
public:
GLRectangle(void);
~GLRectangle(void);
GLRectangle* centerRect(int rectWidth, int rectHeight, int boundWidth=0, int boundHeight=0);
};
GLRectangle.cpp
#include "GLRectangle.h"
GLRectangle::GLRectangle(void)
{
}
GLRectangle::~GLRectangle(void)
{
}
GLRectangle* GLRectangle::centerRect(int rectWidth, int rectHeight, int boundWidth, int boundHeight)
{
if(boundWidth == 0)
{
boundWidth = XPView::getWindowWidth();
}
if(boundHeight == 0)
{
boundHeight = XPView::getWindowHeight();
}
// Set rectangle attributes
left = boundWidth/2 - rectWidth/2;
top = boundHeight/2 + rectHeight/2;
right = boundWidth/2 + rectWidth/2;
bottom = boundHeight/2- rectHeight/2;
return this;
}
,我试图链的功能上的建设对象如下:
wndRect = new GLRectangle()->centerRect(400, 160);
但得到以下错误:
error C2143: syntax error:missing ';' before '->'
有没有办法得到这个工作?
谢谢,它修复了它! – 2010-01-03 15:37:09