由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - Question about
相关主题
[合集] 问个面试题Question about friend in C++
一个小程序差点搞死了g++,怎么回事?url header问题
请教c++的string vector问题,谢谢! (转载)c++ inline问题 (转载)
最初级的白痴C++问题Global(static) variable initialization question
C++ head files help~c++ std::abs(int) ambiguous?
请教有关header file的几个问题namespace defined in another file
新手求问一C++初级问题Spring REST+AFNetworking问题
问个 c++ include 问题how to include header file in other directory?
相关话题的讨论汇总
话题: string话题: question话题: std话题: about话题: using
进入Programming版参与讨论
1 (共1页)
b**n
发帖数: 289
1
我看到各处介绍C++ string的时候,都说要用string,就要有这两句:
#include
using std::string;
但实际上,我在我的机器上只用
using std::string; 居然也可以用了。不知道为什么,哪位达人解达一下,谢谢。
g++ 4.0.2
k****f
发帖数: 3794
2
没代码没真相
在其他地方include了

【在 b**n 的大作中提到】
: 我看到各处介绍C++ string的时候,都说要用string,就要有这两句:
: #include
: using std::string;
: 但实际上,我在我的机器上只用
: using std::string; 居然也可以用了。不知道为什么,哪位达人解达一下,谢谢。
: g++ 4.0.2

q*****g
发帖数: 72
3
some lib files you have included may already include string
but never rely on that, it is not portable.

【在 b**n 的大作中提到】
: 我看到各处介绍C++ string的时候,都说要用string,就要有这两句:
: #include
: using std::string;
: 但实际上,我在我的机器上只用
: using std::string; 居然也可以用了。不知道为什么,哪位达人解达一下,谢谢。
: g++ 4.0.2

t****t
发帖数: 6806
4
什么bug,你抓住了站长的宠物还要JJWW...
b**n
发帖数: 289
5
Right, Thanks a lot.
The following code is OK:
#include
using std::string;
int main(){
string str = "string";
return 0;
}
The following one is NOT OK:
using std::string;
int main(){
string str = "string";
return 0;
}
I guess header file somehow already included . I am not
sure about this.
Thanks a lot.
1 (共1页)
进入Programming版参与讨论
相关主题
how to include header file in other directory?C++ head files help~
auto_ptr_array.h 疑问请教有关header file的几个问题
晕了,用VC写的一个project新手求问一C++初级问题
g++ command line一问问个 c++ include 问题
[合集] 问个面试题Question about friend in C++
一个小程序差点搞死了g++,怎么回事?url header问题
请教c++的string vector问题,谢谢! (转载)c++ inline问题 (转载)
最初级的白痴C++问题Global(static) variable initialization question
相关话题的讨论汇总
话题: string话题: question话题: std话题: about话题: using