我有以下類:我的功能鏈不想工作,爲什麼?
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