草庐IT

ARGUMENT

全部标签

C++ 模板复制构造函数,编译器说 "passing const as this argument discards qualifiers"

我正在尝试创建动态矩阵的模板类。凭借我目前对C++的了解,我设法解决了一些问题,但我被复制构造函数和重载operator=;困住了。换句话说,我无法创建对象的拷贝。在我看来这应该可行,但我的编译器friend告诉我有1个错误:错误:将“constMatrix”作为“intMatrix::getElement(int,int)[withT=int]”的“this”参数传递会丢弃此行的限定符[-fpermissive]:m[i][j]=original.getElement(i,j);当我想创建一个对象时:Matrixm=Matrix(3,3);我的模板类在这里:templateclass

c++ - (C++) 错误 : 'invalid_argument' was not declared in this scope

我正在使用EclipseC/C++和MinGW编译器。我已将标志-std=c++11添加到项目属性中C/C++Build下的MiscellaneousGCCCCompilerSettings中。我知道这可能是一件简单的事情,但我无法解决此错误。Date.h#includeusingnamespacestd;classDate{public:Date(intm=1,intd=1,inty=1900);voidsetDate(int,int,int);private:intmonth;intday;intyear;staticconstintdays[];};日期.cpp#include#

c++ - 警告 C4244 : 'argument' : conversion from 'SIZE_T' to 'DWORD' , 可能丢失数据

我需要在我的代码中有一组重载函数,但我得到了转换wanrings。这是一个测试代码:#includewindows.hvoidf(DWORDarg){...}//voidf(SIZE_Targ){}voidmain(void){DWORDdword=0;SIZE_Tsize_t=dword;f(size_t);}编译器给出警告:test.cpp(11):warningC4244:'argument':conversionfrom'SIZE_T'to'DWORD',possiblelossofdata如果我取消注释voidf(SIZE_Targ)我得到test.cpp(5):errorC

c++ - 错误 : argument of type char* is incompatible with parameter of type LPCWSTR

#include#includeusingnamespacestd;intmain(){char*file="d:/tester";WIN32_FIND_DATAFindFileData;HANDLEhFind;hFind=FindFirstFile(file,&FindFileData);//lineoferrorsaysargumentoftypechar*isincompatiblewithparameteroftypeLPCWSTR}我无法理解错误。错误是什么以及如何解决错误?我正在制作一个控制台应用程序,需要检查目录中是否有文件。 最佳答案

c++ - boost .python : Argument types did not match C++ signature

我在python中调用C++函数时遇到一个奇怪的问题。我公开了一个我想从中调用函数的类:class_>("MyClass",init())//....def("someFunc",&MyClass::someFunc);我得到一个std::shared_ptr来自另一个类的成员变量,该类通过.def_readonly(...)公开当我尝试调用该函数时,出现以下错误:File"pytest.py",line27,intest_funccu.someFunc("string")Boost.Python.ArgumentError:PythonargumenttypesinMyClass.s

parser.add_argument:错误:未识别的参数:true

我在Python2.7中有一个程序,该程序具有一系列代码:parser.add_argument('--skip_train',default=False,help='skiptraining',action='store_true')该代码告诉程序默认情况下进行培训。但是现在我想在没有培训的情况下实施它,因为培训已经完成。因此,我输入了提示:pythonmyprogame.py--skip_trainTrue但这给出了一个错误消息:error:unrecognizedarguments:True应该在提示命令中输入什么以实现该程序?看答案当您使用时action='store_true',您不

c++ - 如何抛出 std::invalid_argument 错误?

我在C++的Fraction类中有一个重载运算符,它旨在从标准输入中获取整数形式的输入,即1/2或32/4并根据这些值初始化一个Fraction对象。它有效,但我无法捕获错误。//getsinputfromstandardinputintheformof(hopefully)int/intstd::istream&operator>>(std::istream&inputStream,Fraction&frac){intinputNumerator,inputDenominator;charslash;if((std::cin>>inputNumerator>>slash>>input

c++ - 警告 C4244 : 'argument' : conversion from 'double' to 'const int' , 可能丢失数据

我正在定义“*”运算符以使用“NumericArray”类模板。代码如下:templateNumericArrayNumericArray::operator*(constT&factor)const{NumericArraynewArray(Size());for(inti=0;i当我尝试将类型为“int”的“NumericArray”(NumericArray)与“*”运算符一起使用时,当“factor”参数为double时:intArray1=intArray1*2.5;我收到以下编译器警告:warningC4244:'argument':conversionfrom'doubl

C++ 谷歌模拟 SaveArg : how to save a pointer argument

我在保存模拟接收到的指针参数时遇到困难。#defineSIZE_OF_DATAtypedefstruct{uint32_tsomeValue1;uint16_tsomeValue2;//othervalueshere}LargeStruct;classSomeClass{public://assumesendDataisagenericfunctionwheredataisactuallypointertoaLargeStructvoidsendData(constuint8_t*data,constuint16_tsize);}classMockClass:publicSomeCla

C++/线程 : No instance of constructor "std::thread::thread" > matches the argument list

我在线程方面遇到了一些问题,因为我对它很陌生。我得到一个:noinstanceofconstructor"std::thread::thread"matchestheargumentlistargumenttypesare(void())恰好在std::threadt1(TestPlay);voidCMusicTCPDlg::OnBnClickedBtplaymusic(){std::threadt1(TestPlay);t1.join();}voidCMusicTCPDlg::TestPlay(){if(CFugue::GetMidiOutPortCount()我引用了一些线程页面,