请问,在不是基于MFC的VC++程序中,怎样使用MFC中的类,比如,CPoint,请大侠们指点!!

解决方案 »

  1.   

    try#include <iostream>
    #include <afxwin.h>using namespace std;int main()
    {
      CPoint pt(1,2);
      cout << pt.x <<"," << pt.y << endl;
      return 0;
    }make sure you use /MD compiler option,for example
    D:\>vcvars32
    D:\>cl /MD testcpp.cpp
      

  2.   

    using namespace std; 这个有什么用
    /MD 有什么用
      

  3.   

    程序中,有#include <windows.h>,再添上#include <afxwin.h>
    有错误提示:d:\program files\microsoft visual studio\vc98\mfc\include\afxv_w32.h(14) : fatal error C1189: #error :  WINDOWS.H already included.  MFC apps must not #include <windows.h>
    Error executing cl.exe.a.exe - 1 error(s), 0 warning(s)
      

  4.   

    改变一下包含头文件的顺序,把#include <windows.h>放到#include <afxwin.h>之前:#include <windows.h>,
    #include <afxwin.h>
    另外在Project/Setting/General中选择using MFC in a shared DLL。很多MFC类需要多线程版,所以还需要在Project/Setting/ C/C++ 的 Code Generation的use run-time library 中选择多线程,比如Debug Multithreaded DLL(for Debug版) 或者Multithreaded DLL(for Releas版)
      

  5.   

    只需#include <afx.h>,然后在Project/Setting/General中选择using MFC in a shared DLL。就这样就可以了,我经常在Console程序里面用MFC的类,比如CList,CMap等等。
      

  6.   

    因为cout是在标准库iostream里面声明的,而且用namespace封装了起来,你如果不用using指示符的话则cout等所有标准库里面的所有类对你的程序是不可见的。
      

  7.   

    我试了一下,顺序应该是:
    #include <afxwin.h>
    #include <windows.h>
    多谢大家了