在消息映射函数的条件语句在编译里出现下面这样的错误
binary '&&':'class CPoint' does not define this operator or a type acceptable to the predefined operator
句子是这样的
if(m_IsDrawing&&(nFlags&MK_LBUTTON)&&m_Canvas.PtInRect(point))
请问,这是什么错误。
如果要在这个映射函数里进行运算符重载,该怎么做!!

解决方案 »

  1.   

    你话都没说清,谁给你解答呀?不过看样子你是把CPoint类型的对象用于&&比较了。
    你不会别干这么无聊的事吗?钻牛角尖!
      

  2.   

    查查m_Canvas.PtInRect(point)的返回类型是什么。
      

  3.   

    m_Canvas.PtInRect(point)肯定不是这样用的
      

  4.   

    我的意思是
    if(m_IsDrawing&&(nFlags&MK_LBUTTON)&&m_Canvas.PtInRect(point))
    这句在编译时编译器出现上面这样的错误提示,不知道这个是什么样的错误,该怎么改!!
      

  5.   

    if(m_IsDrawing&&(nFlags&MK_LBUTTON)&&(m_Canvas.PtInRect(point)))
    加个括号
      

  6.   

    这是一个例题,是做一个简单的画图对话框,在对话框里左边只有一个clear的按钮,右边是画布,在画布里只要按住鼠标就可以画图了,按下clear清屏。
    这个函数是处理WM_MOUSEMOVE这个消息的。原型是
    void CPaintRamaDlg::OnMouseMove(UINT nFlags,CPoint point)
    {
     CDialog::OnMouseMove(nFlags, point);
    }
    上面那一句我是照样搬进去的
      

  7.   

    改为
    BOOL bBool = m_Canvas.PtInRect(point);
    if(m_IsDrawing&&(nFlags&MK_LBUTTON)&&bBool)
    ...
    我猜
      

  8.   

    我曾把上面条件语句里的&&改为||这个符号后,编译出来的还是一样的错误;
      

  9.   

    CaptainIII这位老兄,照你的话,改一下还是原先那个错误啊
      

  10.   

    不明白你的意思了,不过nFlags&MK_LBUTTON这样的写法肯定规范,不过在这儿,也许不会错
      

  11.   

    CaptainIII老兄,我是的意思是,刚才用你的办法试了一下,但编译出来的还是binary '&&':'class CPoint' does not define this operator or a type acceptable to the predefined operator
    这个错误
      

  12.   

    那句英文不是说了吗?CPoint里没有对象&&,m_Canvas.PtInRect(point)的返回值。或者你先调用这个函数,返回的结果参与运算!
      

  13.   

    别想偏了,问题一定是你误用了CPoint的格式,自少是问题之一,这不用怀疑
      

  14.   

    看错误提示的字面消息,好像是运算符&&没有定义的样子,会不会和运算符的重载有关系啊!!
      

  15.   

    The specified operator could not be used in its predefined form. To use the operator you must overload it for the apropriate type, or define a conversion to a type for which the operator is defined. If you’ve encountered this error on code which compiled with an earlier version of Visual C++, please read Technote: Improved Conformance to ANSI C++ for more information.The following is an example of this error:class C
    {
       public:
       C();
    } c;class D
    {
       public:
       D();
       D operator <<( C& );
    } d;
    void main()
    {
       d >> c;   // error
       d << c;   // OK, operator << defined
    }