新手求教:我的vs2010库里为什么找不到CString类?除了vb,f#,c#没装,其它都装了,而且我用联网帮助也找不到???

解决方案 »

  1.   

    CString是MFC的类,你要用的话,就必须有MFC支持!跟VB...之类没关系
      

  2.   

    那我在vs2010本地库里怎么加入MFC,找了也没有,是不是要在线安装啊,,,
      

  3.   

    虽然没用过2010, 但是还是回一下吧。
    你建的是什么工程? 只有MFC支持的工程才能用CString,如果找不到,用string代替吧。
      

  4.   

    对,是C++ MFC工程,不同的工程,对库也有影响吗
      

  5.   

    有CString啊,MFC里直接用就行了,不过MSDN搜索的话,要搜索CStringT
      

  6.   

    咦,CStringT是有,但是两个好象不一样啊,而且有些函数没有,vs2010里用CString是没问题
      

  7.   

    VS2005以后的CString已经完全用C++模板实现了,名字就叫CStringT,而CString是它的一个别名。
      

  8.   

    你要用CString的话,要么用MFC应用程序向导创建MFC程序。
    要么就在Win32程序里#include <afx.h>并在工程配置里选上使用MFC的项。
      

  9.   

    我就用vc2010,刚刚就你的问题创建了一个MFC基于对话框的应用程序,可以直接使用CString的。
    如果你的不支持,请查看stdafx文件中引入的.h库,其中#include <afxwin.h> 是很重要的。
    下面是我的stdafx.h文件内容
    // stdafx.h : include file for standard system include files,
    // or project specific include files that are used frequently,
    // but are changed infrequently#pragma once#ifndef _SECURE_ATL
    #define _SECURE_ATL 1
    #endif#ifndef VC_EXTRALEAN
    #define VC_EXTRALEAN            // Exclude rarely-used stuff from Windows headers
    #endif#include "targetver.h"#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS      // some CString constructors will be explicit// turns off MFC's hiding of some common and often safely ignored warning messages
    #define _AFX_ALL_WARNINGS#include <afxwin.h>         // MFC core and standard components
    #include <afxext.h>         // MFC extensions#ifndef _AFX_NO_OLE_SUPPORT
    #include <afxdtctl.h>           // MFC support for Internet Explorer 4 Common Controls
    #endif
    #ifndef _AFX_NO_AFXCMN_SUPPORT
    #include <afxcmn.h>             // MFC support for Windows Common Controls
    #endif // _AFX_NO_AFXCMN_SUPPORT#include <afxcontrolbars.h>     // MFC support for ribbons and control bars