明飞的技术园地

笨鸟先飞
  博客园  :: 新随笔  :: 联系 :: 管理

c++Permer4学习的一些体会一之命名空间

Posted on 2006-12-07 19:48  明飞  阅读(282)  评论(0编辑  收藏  举报
; states our intent to use these names from the namespace std
     using std::
     using std::string;
     int main()
     {
      string s;       // ok: string is now a synonym for std::string
      cin >> s;       // ok: cin is now a synonym for std::cin
      cout << s;      // error: no using declaration; we must use full name
      std::cout << s; // ok: explicitly use cout from namepsace std
    //要使用命名控件,一般有如下几种方式
#include<iostream>   

1.using   std::cin;  
      using   std::cout;  
      cout<<"Hello\n";   
 2.using   namespace   std;  
      cout<<"Hello\n";   
3.std::cout<<"Hello\n";