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. |