草庐IT

ARGUMENT

全部标签

c++ - 将返回 void 但具有整数参数的函数作为 ARGUMENT 本身传递给另一个函数

我最近开始使用c++开发OpenCV。我在使用以下代码时遇到问题。#include"cv.h"#include"highgui.h"intg_slider_position=0;CvCapture*g_capture=NULL;voidonTrackbarSlide(intpos){cvSetCaptureProperty(g_capture,CV_CAP_PROP_POS_FRAMES,pos);}intmain(intargc,char**argv){cvNamedWindow("Example3",CV_WINDOW_AUTOSIZE);g_capture=cvCreateFil

c++ - 为什么我收到错误 : initializing argument 1 of 'Item::Item(int)' [-fpermissive] in Eclipse when I try to compile my C++ code?

我是C++的新手,在盯着它看了太久之后终于放弃了尝试编译它。编译器似乎出于某种原因拒绝了头文件中的构造函数原型(prototype)......我无法弄清楚它有什么问题。项目.h:#ifndefITEM_H_#defineITEM_H_classItem{public:Item(int);//ThislineiswhatEclipsekeepsflaggingupwiththeerrorinthetitlevirtual~Item();Item*getNextPtr();intgetValue();voidsetNextPtr(Item*);};#endif/*ITEM_H_*/在我的

c++ - 错误 : Use of class template requires template argument list

当我尝试运行我的程序时,此错误显示为“errorC2955:'FOURTEEN':useofclasstemplaterequirestemplateargumentlist”#includeusingnamespacestd;templateclassFOURTEEN{private:Ta[n];public:voidReadData();voidDisplayData();};voidFOURTEEN::ReadData(){for(inti=0;i>a.[i];}voidFOURTEEN::DisplayData(){for(inti=0;i>a.[i]P;//Readdatai

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++ --- 错误 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++ - C++中的默认参数有一些特殊的属性吗?

这是一道面试题,不是作业。测试已经完成。以下哪些关于C++中默认参数的陈述是正确的?A.DefaultArgumentcannotbeofauser-definedtype.B.DefaultArgumentcanneverprecedenon-defaultargumentsC.DefaultArgumentcannotbeofpointertype.D.DefaultArgumentexistinglobalheapnotfunction'sstackE.DefaultArgumentarenotconsideredforgeneratingthefunction'ssignatu

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这个语法是否存在或者这是不可能的? 最佳答案 不,在当前语法中这是不可能的。