用了using namespace std后还要这样std::cout 才能正常编译

我用的DEV-C++
图片说明
加上后就没问题了,求高手解答!

1.你的using namespace std定义在何处?
2.是否自己有定义了有同名的cout 标识?

where is you using namespace std

可不可以看看你的引用文件代码
如果你同时使用.h和using
所以错误
using namespace std;是指你所包含的那些变量和函数在std的名字空间当中,但是在.h当中,这些变量和函数在全局的空间当中,所以出错

把using namespace std放在引入头文件代码的下一行试试

添加的位置在代码最上面,然后换VS试试

贴出你的代码,没看到你写using,你写在哪里了?

  1. 首先没看到你写的using namespace,一般在当前文件include之后写出来。
  2. 尽量使用std::,如果有其它命名空间的话,也尽量少用using namespace, 避免命名空间之间的冲突。

这样试试:
#include
(如果还要调用别的库 就在这里增加)
using namespace std;
int main()
{
……..
}

图片说明

#include
#include
#include
#include
#include
#include
#include
using namespace std;
class make14Arry{
public: void myMake14Arry(){
int intCount=0;//符合条件的个数变量,初始值为0
int countInfile=0;//输入文件的个数
int maxDigit=16383;//最大的要转换的数
vector vecStr;//vector是动态的分配连续内存
vector::iterator it;
for(int intC=0;intC<maxDigit;intC++){//从0开始循环
char charArr[15];
char charArr1[15];
itoa(intC,charArr1,2);//指针越界
int i=strlen(charArr1);
if (i!=14)
{
for (int j=0; j<14-i; j++)//不足14位的补0
{
charArr[j]='0';
}

int ii=0;
for (int k=14-i; k<15; k++)
{

                if (ii<i)
                {
                    charArr[k]=charArr1[ii];
                }else
                {
                    charArr[k]='\0';
                }   
                ii+=1;
            }
    }else 
    {
        int iii=0;
        for (int n=0; n<15; n++)
        {
            if (iii<i)
            {
                charArr[n]=charArr1[iii];
            }else
            {
                charArr[n]='\0';
            }
            iii+=1; 
        }       
    }
    if(strstr(charArr,"101")==NULL&&strstr(charArr,"11")==NULL
    &&strstr(charArr,"0000000000")==NULL
    &&strstr(charArr,"00000000000")==NULL
    &&strstr(charArr,"000000000000")==NULL
    &&strstr(charArr,"0000000000000")==NULL
    &&strstr(charArr,"00000000000000")==NULL){
        intCount++; 
        vecStr.push_back(charArr);
    }else{
            continue;
    }

}
ofstream fout("EMF.txt");
if(!fout){
    std::cout<<"EFM.txt已存在,无需再次存储。"<<endl;
}else{
        for(it=vecStr.begin();it!=vecStr.end();++it){
            fout<<*it<<endl;
            countInfile++; 
        }
        fout.close();
}
if(countInfile==intCount){
        std::cout<<"输入成功"<<endl;
} 
vecStr.clear();
return;

}
};

/* run this program using the console pauser or add your own getch, system("pause") or input loop /
int main(int argc, char
* argv){

make14Arry m;
m.myMake14Arry();
system("pause");
return 0;

}