函数声明如下
CWnd::SetCaretPos
static void PASCAL SetCaretPos( POINT point );
注意参数个是POINT结构体
而在调用的时候是
SetCaretPos(CPoint),也就是说传递去一个CPoint对象,
结构体和类应该是两码事,可这样编译却没有出错??

解决方案 »

  1.   

    因为CPoint的定义是:
    class CPoint : public tagPOINT
    CPoint的类是从tagPOINT也就是POINT结构派生的类。
      

  2.   

    CPoint
    The CPoint class is similar to the Windows POINT structure. It also includes member functions to manipulate CPoint and POINT structures. A CPoint object can be used wherever a POINT structure is used. The operators of this class that interact with a “size” accept either CSize objects or SIZE structures, since the two are interchangeable.Note This class is derived from the tagPOINT structure. (The name tagPOINT is a less-commonly-used name for the POINT structure.) This means that the data members of the POINT structure, x and y, are accessible data members of CPoint.#include <afxwin.h>摘自MSDN
      

  3.   

    POINT是CPoint基类,CPoint包含POINT
      

  4.   

    没有问题,许多MFC类都可以这样处理,比如CRect和RECT之间也这样,估计是重载了运算符.
      

  5.   

    恩,确实相楼上说的,CRect和RECT之间也这样