预处理指令using namespace std

来源:互联网 发布:手机屏幕宠物软件 编辑:程序博客网 时间:2024/06/05 09:42

要使用cin和cout,必须使用预处理指令

#include<iostream>


如果没有using namespace std,标识符应为std::cin和std::cout

#include<iostream>#include<stdio.h>using namespace std;int main(){cout << "Enter two numbers:" << endl;int v1, v2;cin >> v1 >> v2;cout << "The sum of" << v1 << "and" << v2<< "is" << v1 + v2 <<endl;system("pause");return 0;}
或者
#include<iostream>  #include<stdio.h>  int main()  {      std::cout << "Enter two numbers:" << std::endl;      int v1, v2;      std::cin >> v1 >> v2;      std::cout << "The sum of" << v1 << "and" << v2          << "is" << v1 + v2 << std::endl;      system("pause");      return 0;  }