免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2784 | 回复: 1
打印 上一主题 下一主题

求教“类对象加内有数字的圆括号是什么意思啊”,如origin(3) [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-01-16 16:16 |只看该作者 |倒序浏览
类对象加内有数字的圆括号是什么意思啊,如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;}

论坛徽章:
0
2 [报告]
发表于 2012-01-16 16:48 |只看该作者
非常抱歉,找到问题所在,原来类有个友元函数,对括号内加数值就是返回数组。不知道怎么删帖,现在这回复下,不想耽误大家阅读的时间!抱歉!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP