您的位置:首页 > 编程语言 > C语言/C++

C++,cout和std::cout的区别

2016-03-24 14:49 267 查看
#include "stdafx.h"
#include <stdlib.h>
#include <iostream>
using namespace std;
int main() {
//using std::cout;
//using std::endl;
cout << "Hello, world" << endl;/////前面已定义std,则后面可以直接调用,不必写std::cout...
//using std::cout;
//using std::endl;
//std::cout<<"hello world."<<std::endl;
//cout<<"hello world."<<endl;
system("pause");
return 0;
}
Hello, world
请按任意键继续. . .

-------------------------------------------------------------------------------------------------------------

#include "stdafx.h"
#include <stdlib.h>
#include <iostream>
//using namespace std;
int main() {
using std::cout;
using std::endl;/////此处定义std
cout << "Hello, world" << endl;//////此处可以直接调用
//using std::cout;
//using std::endl;
//std::cout<<"hello world."<<std::endl;
//cout<<"hello world."<<endl;
system("pause");
return 0;
}Hello, world

请按任意键继续. . .

-------------------------------------------------------------------------------------------------------------
#include "stdafx.h"
#include <stdlib.h>
#include <iostream>
//using namespace std;
int main() {
//using std::cout;
//using std::endl;
//cout << "Hello, world" << endl;
//using std::cout;
//using std::endl;
std::cout<<"hello world."<<std::endl;/////前面没有定义std,则在调用cout时,需写成std::cout...才行
//cout<<"hello world."<<endl;
system("pause");
return 0;
}hello world.

请按任意键继续. . .
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  C++ std cout