给函数赋值是什么意思

5 views
Skip to first unread message

谢晓阳

unread,
Mar 17, 2014, 4:36:29 AM3/17/14
to swjtu_op...@googlegroups.com
有俩成员函数是这个样子滴

        char & position(int row,int col)
        {return data[row * width + col];}
        char position(int row,int col) const
        {return data[row * width + col];}

又有这样的调用

            position(i + row,j + col) = p.position(i,j);

这样做会改变 data 相应位置上的值,上面这行给函数赋值是什么意思。

28hua

unread,
Mar 17, 2014, 10:37:41 AM3/17/14
to swjtu_op...@googlegroups.com
汗,返回值是引用可以作为一个左值,像重载 [] 时一样

在 2014年3月17日星期一UTC+8下午4时36分29秒,28hua写道:
Reply all
Reply to author
Forward
0 new messages