我想问一下为什么第二个可以输出字符串,而第一个只能输出地址啊

[复制链接]
查看11 | 回复3 | 2009-3-21 20:48:50 | 显示全部楼层 |阅读模式
// STR.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include "afx.h"
#include
#include
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
CString str="hello world";
cout<<str<<'\n';
string str1("hello China")<<endl;
cout<<str1;
return 0;
}

回复

使用道具 举报

千问 | 2009-3-21 20:48:50 | 显示全部楼层
CString 这种数据类型是MFC 里的...
回复

使用道具 举报

千问 | 2009-3-21 20:48:50 | 显示全部楼层
第一个改为 cout<<str.getbuffer() 或者重载CString 的& 运算符...
回复

使用道具 举报

千问 | 2009-3-21 20:48:50 | 显示全部楼层
这个题目好像是一个什么上面的吧...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行