本文介绍了错误:对于操作符&lt;&lt;&lt; in std :: operator&lt;&lt; &lt; std :: char_traits&lt; char&gt; &gt;(*&amp; std :: cout),((const char *)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 错误:中的无匹配 std :: operator< < std :: char_traits< char> >(*& std :: cout),((const char *) #include< iostream> 使用命名空间std; int ContarDig(int num){ int contar = 1; while(num> 9){ num = num / 10; contar = contar + 1; } return contar; } void arreglo(int a [],int t){ for(int i =(ContarDig(t)-1); i> = 0; i-){a [i] = t%10; t = t / 10; cout int l =(ContarDig(x)/ 2) ); int i = 0; int f = ContarDig(x); for(l; l> = 0; l-){ int b = i]; A [i] = A [f]; A [f] = b; i ++; f-; } $ b (i; i cout =} } int main(int argc,char * argv []){ int x; cout<<Digite un numero para invertir<< endl; cin>> x; int A [ContarDig(x)]; arreglo(A,x); cout<<========================================= =============================<< endl; cout<< El arreglo invertido es:<反转(A,x) endl; return 0; } 所以,我想知道如何解决我的问题,具有数组并将其反转。 #include< iostream> using namespace std; int ContarDig(int num){ int contar = 1; while(num> 9){ num = num / 10; contar = contar + 1; } return contar; } void arreglo(int a [],int t){ for(int i =(ContarDig(t)-1); i> = 0; b $ ba [i] = t%10; t = t / 10; cout<<valor posicion [< i<< ] =<< a [i]<< endl; } } void invertir(int A [],int x){ int l =(ContarDig(x)/ 2); int i = 0; int f = ContarDig(x)-1; for(l; l> = 0; l - ){ int b = A [i]; A [i] = A [f] A [f] = b if(ContarDig(x)== 2) break; i ++; f--; } } int main(int argc,char * argv []){ int x; cout<<Digite un numero para invertir<< endl; cin>> x; int A [ContarDig(x)]; arreglo(A,x); cout<<========================================= =============================<< endl; cout<< El arreglo invertido es:<<< endl; invertir(A,x); for(int i =(ContarDig(x)-1); i> = 0; i-){ cout<valor posicion [< i<< ] =<< A [i]<< endl; } return 0; } 这是我的程序的新版本, p> 解决方案与标题相关的错误源于此行: code> cout<< El arreglo invertido es:<反转(A,x) endl; 函数 invertir()返回 void ,无法打印。对于编译器,这就像写 std :: cout<< ;; ,这是无效的。将函数的返回类型更改为一个适当的,或者,不要尝试打印它。调用函数并允许它正常打印(因为函数中调用 std :: cout :: operator<<())。 您应该尝试解释这些错误。虽然错误你得到的这样的简单的错误跨页(我有194行错误),只改变一行代码修复所有。不要恐吓,检查你给的行号,并查看该代码的简单错误。 我的错误看起来像这样,还有更多。 test92.cpp:在函数'int main(int,char **)': test92.cpp:41:39:error:没有匹配'operator<<'(操作数类型'std :: basic_ostream< char>'和'void') p>#include <iostream>using namespace std;int ContarDig (int num){ int contar=1; while (num>9){ num=num/10; contar=contar+1; } return contar;}void arreglo(int a[], int t){ for(int i=(ContarDig(t)-1); i>=0; i--){ a[i]=t%10; t=t/10; cout <<"valor posicion[" << i << "]= "<<a[i]<<endl; }}void invertir(int A[],int x){ int l=(ContarDig(x)/2); int i=0; int f=ContarDig(x); for(l;l>=0;l--){ int b=A[i]; A[i]=A[f]; A[f]=b; i++; f--; } for (i;i<=ContarDig(x);i++){ cout <<"valor posicion[" << i << "]= "<<A[i]<<endl; }}int main(int argc, char *argv[]) { int x; cout<<"Digite un numero para invertir"<<endl; cin>>x; int A[ContarDig(x)]; arreglo (A,x); cout<<"========================================================================"<<endl; cout<< "El arreglo invertido es:" << invertir(A,x) << endl; return 0;}So, I would like to know how to solve my problem, its objective is to have an array and invert it.#include <iostream>using namespace std;int ContarDig (int num){ int contar=1; while (num>9){ num=num/10; contar=contar+1; } return contar;}void arreglo(int a[], int t){ for(int i=(ContarDig(t)-1); i>=0; i--){ a[i]=t%10; t=t/10; cout <<"valor posicion[" << i << "]= "<<a[i]<<endl; }}void invertir(int A[],int x){ int l=(ContarDig(x)/2); int i=0; int f=ContarDig(x)-1; for(l;l>=0;l--){ int b=A[i]; A[i]=A[f]; A[f]=b; if (ContarDig(x)==2) break; i++; f--; }}int main(int argc, char *argv[]) { int x; cout<<"Digite un numero para invertir"<<endl; cin>>x; int A[ContarDig(x)]; arreglo (A,x); cout<<"========================================================================"<<endl; cout<< "El arreglo invertido es:" <<endl; invertir(A,x); for (int i=(ContarDig(x)-1);i>=0;i--){ cout <<"valor posicion[" << i << "]= "<<A[i]<<endl; } return 0;}This is the new version of my program and now it runs perfectly. 解决方案 The error related to the title stems from this line:cout<< "El arreglo invertido es:" << invertir(A,x) << endl;The function invertir () returns void, and can't be printed. To the compiler, that's like writing std:: cout <<;, which is invalid. Change the return type of the function to one appropriate, or, simply don't try to print it. Call the function and allow it to print normally (since there's calls to std:: cout:: operator << () in the function).You should attempt to interpret these errors that you get. Although the errors you get for such simple mistakes span pages (I got 194 lines of errors), changing just one line of code fixes it all. Don't be intimidated, check the line number you are given, and look around that code for simple mistakes.My error looked like this, and a whole bunch more.test92.cpp: In function ‘int main(int, char**)’:test92.cpp:41:39: error: no match for ‘operator<<’ (operand types are ‘std::basic_ostream<char>’ and ‘void’)That's all you need. 这篇关于错误:对于操作符&lt;&lt;&lt; in std :: operator&lt;&lt; &lt; std :: char_traits&lt; char&gt; &gt;(*&amp; std :: cout),((const char *)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
09-03 09:56