您的位置:首页 > 其它

Win 32 控制台程序中使用CString

2015-01-27 18:02 162 查看
Win32控制台程序中,无法直接使用MFC的CString,做要使用需要进行如下步骤:

第一步:项目属性--->配置属性--->常规--->MFC的使用 由原来的使用标准Windows库,改为 在静态库中使用MFC 或者在共享DLL中使用MFC都可以;

第二步:包含头文件 #include <afxwin.h>

举例:前提按照第一步更改配置

#include <afxwin.h>

class Test1

{

public:

Test1(int n)

{

m_Name = n;

}

~Test1()

{

}

private:

int m_Name;

};

class Test2

{

public:

explicit Test2(int n)

{

m_Name = n;

}

~Test2()

{

}

int m_Name;

};

int main()

{

Test1 test1 = 11;

Test2 test2(12);

CString strTest1 = L"Test1:" ;

system("pause");

return 0;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: