首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

c++小疑点,请下新手

2012-02-28 
c++小问题,请高手指点下新手!为什么#include iostream.h不需要用using name space std而用#include io

c++小问题,请高手指点下新手!
为什么#include <iostream.h>不需要用using name space std;
而用#include <iostream> 不写using name space std;
会提示error C2065: 'cout' : undeclared identifier


#include <iostream.h>
void Change( int (*p)[3]) 

int temp; 
for (int i=0; i<3; i++ ) 

for (int j=0;j<3; j++) 

if(j>i) 

temp = *(*(p+i)+j); 
*(*(p+i)+j) = *(*(p+j)+i); 
*(*(p+j)+i) = temp; 




void main() 
{
int i,j;
int arr[2][3] = {{1,2,3},{4,5,6}}; 
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cout<<arr[i][j]<<" ";
}
cout<<endl;
}
cout<<"开始转置..."<<endl;
Change(arr); 
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cout<<arr[i][j]<<" ";
}
cout<<endl;
}
}


[解决办法]
参考百度知道:http://zhidao.baidu.com/question/29475316.html
<iostream>表示你使用的是标注命名空间,也就是在程序开始应该有这么一句话 
using namespace std ; 
这是遵循c++标准的 
<iostream.h> 
则没有遵循c++标准 


而用#include <iostream> 不写using name space std; 
会提示error C2065: 'cout' : undeclared identifier 
因为cout在标准名称空间std中定义,也可以实用 using std::cout;

热点排行