草庐IT

argument2

全部标签

c++ - xutility.h 错误 C2064 : term does not evaluate to a function taking 2 arguments

我有问题要问。我创建了一个名为AstarPlanlama的类并具有以下2个函数:boolAstarPlanlama::nodeComp(constNode*lhs,constNode*rhs){returnlhs->FF;}voidAstarPlanlama::enKucukFliNodeBul(std::list*OPEN){std::list::iteratorit=std::min_element(OPEN->begin(),OPEN->end(),&AstarPlanlama::nodeComp);OPEN->sort(&AstarPlanlama::nodeComp);Q=O

c++ - 候选函数不可行 : 1st argument ('const Node *' ) would lose const qualifier

我正在使用内置的C++编写有向图(有向图)类unordered_map>数据结构,其中Node和Edge是我自己定义的两个结构体。在类里面我写了一个containsNode()搜索Node的方法在图中。这是containsNode()方法体:boolDiGraph::containsNode(constNode*n)const{auto::const_iteratorit=digraph.find(n);return(it==digraph.end());}digraph是unordered_map>类型的DiGraph的私有(private)成员.但是,编译器会生成以下错误:erro

c++ - 了解 "template argument is invalid"错误消息

考虑代码:#include#includestructtest1{voidInvoke(){};};structtest2{templatevoidInvoke(){};};enumclassInvokableKind{NOT_INVOKABLE,INVOKABLE_FUNCTION,INVOKABLE_FUNCTION_TEMPLATE};templatestructget_invokable_kind{conststaticInvokableKindvalue=InvokableKind::NOT_INVOKABLE;};templatestructget_invokable_ki

c++ - 错误 : no instance of overloaded function "std::make_shared" matches the argument list

查看ApreviousstackQuestionstd:make_sharedvsstd::shared_ptr,我试图在一个uni项目中实现它。这是之前的“问题”:Ican'tthinkofanysituationwherestd::shared_ptrobj(newObject("foo",1));wouldbepreferredtoautoobj=std::make_shared("foo",1);因此我采用了这段代码:std::shared_ptrpT1(newTriangle(pCanvas,30,30,30,60,60,30,255,0,0));并将其修改为这段代码:aut

c++ - 哪个更好 : returning tuple or passing arguments to function as references?

我创建的代码中有两个函数returnValues和returnValuesVoid。一个返回2个值的元组,另一个接受参数对函数的引用。#include#includestd::tuplereturnValues(constinta,constintb){returnstd::tuple(a,b);}voidreturnValuesVoid(int&a,int&b){a+=100;b+=100;}intmain(){auto[x,y]=returnValues(10,20);std::cout我读到了http://en.cppreference.com/w/cpp/language/st

C++ --- 错误 C2664 : 'int scanf(const char *,...)' : cannot convert argument 1 from 'int' to 'const char *'

我是C++的新手,我正在尝试构建这个非常简单的代码,但我不明白为什么会出现此错误:Error1errorC2664:'intscanf(constchar*,...)':cannotconvertargument1from'int'to'constchar*'代码如下://lab.cpp:Definestheentrypointfortheconsoleapplication.//#include"stdafx.h"#includeintmain(intargc,char*argv[]){introw=0;printf("Pleaseenterthenumberofrows:");sc

c++ - 运行编译程序 - "Invalid argument"

我有一个简单的HelloWorldC++程序(main.cpp):#includeusingnamespacestd;intmain(void){cout我编译通过g++-Wall-pedantic-Wno-long-long-Werror-cmain.cpp然后添加“可执行”权限chmod+xmain.o并尝试运行它./main.o我的控制台返回-bash:./main.o:Invalidargument我在干什么? 最佳答案 -c选项指示编译器只编译“目标文件”中的源文件,而不链接它。如果没有链接步骤,您获得的目标文件不是可执行

c++ - 默认参数 : can only the last argument(s) be left?

我知道可以做类似的事情:intfoo(inta=0,intb=1){returna+b;}然后在没有默认参数的情况下使用它,例如:foo();//a=0,b=1->1或将最后一个作为默认值,例如:foo(2);//a=2andb=1default->3但是我的问题是:是否可以为第一个参数(a)使用默认值并给出第二个参数(b)的值我的第一个想法是这样做(行不通!):foo(,2);//a=0defaultandb=2这个语法是否存在或者这是不可能的? 最佳答案 不,在当前语法中这是不可能的。

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#