C++ #include<string> 和 using std::string
来源:互联网 发布:2017淘宝双十二红包 编辑:程序博客网 时间:2024/06/11 15:39
今天,偶尔写了一个小小的程序,关于字符串问题程序。比如,我想连续打印用户输入的字符串。
#include<string>using std::cin;using std::cout;using std::endl;int main(void){string text;while(cin >> text)cout<<text<<endl;system("pause");return 0;}
程序编译不过,原因是:'string' : undeclared identifier,但是我已经#include<string>,预处理过string头文件,为什么不能使用string?C++中引入了名称空间,使用类时,必须指定是哪个空间的类,在这个问题上,string类属于标准库空间std,所以必须声明使用哪个空间的string类,加上一句 using std::string。这个程序就可以运行了。
0 0
- C++ #include<string> 和 using std::string
- C++当中,#include <string> 和 using std::string
- using namespace std 和 include <string>的区别
- 关于using std::string
- C\C++关于string.h头文件和string类 using namespace std
- C\C++关于string.h头文件和string类 using namespace std
- std::string 和 c风格字符串
- string类 和 std::string
- std::string::find() 和 std::string::npos
- std::string::find() 和 std::string::npos
- std::string::find() 和 std::string::npos
- std::string::find() 和 std::string::npos
- std::string::find() 和 std::string::npos
- std::string::find() 和 std::string::npos
- std::string::find() 和 std::string::npos
- std::string::find() 和 std::string::npos
- #include <string> 和 #include <string.h>
- #include <iostream>和using namespace std;
- NOIP模拟20150904总结
- matlab的plot调用函数不能用了,总出现错误:Attempt to execute SCRIPT plot as a function
- 基于R做相关分析
- 【Python系列3】两个txt文件通过id进行关联
- UVa 140:Bandwidth(暴力)
- C++ #include<string> 和 using std::string
- hdu4901The Romantic Hero dp
- 面试题-随机生成数
- 063 接口的调用及方法的重写
- HDU 5033 Building (2014年北京赛区网络赛B题)
- JAVA基础笔记之五 表达式5-4.6==0.4的值是什么?
- 分享《学习linux几点忠告》
- Word Break
- 2014编程之美资格赛题目2 : 大神与三位小伙伴(2014-04-12)