今天看书时碰到一个挺下的程序,但是运行了之后感觉挺有意思的~~~
#include <iostream>
#include <string>
using namespace std;
int main()
{
string word;
while (cin >> word)
{
cout << "word read is:" << word << '/n';
}
cout << "ok:no more words to read: bye!/n";
return 0;
}
当不使用名字空间std是,而使用.h的头文件时编译后会发现报告:
error C2065: 'string' : undeclared identifier
error C2146: syntax error : missing ';' before identifier 'word'
error C2065: 'word' : undeclared identifier
是错误,why?感觉挺有那么一点味道,也许这就是小处的魅力吧~~~其实我也不知道为了么,希望以后能开出点门道来~~~今天先记下来了~~~