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

#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)