草庐IT

some_argument

全部标签

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++ - 从 std::tuple<some_types...> 开始创建子元组

让我们假设一个std::tuple给出。我想创建一个新的std::tuple其类型是在[0,sizeof...(some_types)-2]中索引的类型.例如,假设起始元组是std::tuple.我想获得一个定义为std::tuple的子元组.我对可变参数模板很陌生。作为第一步,我尝试写一个struct负责存放不同类型的原件std::tuple目的是创建一个新的同类元组(如std::tuplenew_tuple)。templatestructtype_list;templatestructtype_list:publictype_list{typedefTtype;};template

c++ - 嵌套命名空间 : where should default template arguments go? 中模板类的前向声明

我在嵌套命名空间中有一个模板类的前向声明namespacen1{namespacen2{templatestructA;}usingn2::A;}接着是一个定义,实际上它在不同的文件中,中间有一些东西:structX{};namespacen1{namespacen2{templatestructA{};}usingn2::A;}那么以下总是可以的:n1::n2::Aa;但是这个捷径n1::Aa;在clang中给出编译错误error:toofewtemplateargumentsforclasstemplate'A'除非我删除前向声明;g++两者都接受。clang似乎保留在第一个不包含

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