- 论坛徽章:
- 0
|
类对象加内有数字的圆括号是什么意思啊,如origin(3),代码如下,origin是Point类对象,在另外一个类Rect中调用时使用了origin(3),见下Rect.cc代码,不知是啥意思啊,Point类构造函数中也没只有一个数值的参数啊。摘出这段代码在vs2008里试了下说:"error C2064: term does not evaluate to a function taking 1 arguments”,费解啊,望高手给解答下,谢谢!
class Point {
private:
double x[4];
public:
Point(double xx = 0, double yy = 0, double zz = 0, double m = 0);
Point(const Point &);
Point(const float3 &);
Point(const float4 &);
Point(double *);
~Point(void) {};
};
class Rect {
private:
Point origin;
Vector vx, vy;
public:
Rect(void);
Rect(const Point& p, const Vector& v1, const Vector& v2);
~Rect(void) {};
void SetPartMass(double mass);
};
"Rect.cc"代码中调用了origin(3),代码如下:
#include "Rect.h"
#include "Point.h"
#include "Vector.h"
Rect::Rect(void)
{
origin = Point(0, 0, 0);
vx = Vector(0, 0, 0);
vy = Vector(0, 0, 0);
}
Rect::Rect(const Point &p, const Vector& v1, const Vector& v2)
{
origin = p;
vx = v1;
vy = v2;
}
void Rect::SetPartMass(double mass)
{
origin(3) = mass;} |
|