草庐IT

e-implicitly-typed-declarations-p

全部标签

c++ - 错误 : cannot declare variable ‘bg’ to be of abstract type ‘cv::BackgroundSubtractorMOG2’ in OpenCV 3

我最近在我的ubuntu14.10系统中安装了OpenCv并且我正在运行一个程序并且正在运行cv::BackgroundSubtractorMOG2我遇到了一个错误。错误是cannotdeclarevariable‘bg’tobeofabstracttype‘cv::BackgroundSubtractorMOG2’为什么我会遇到这个错误我的代码示例intmain(intargc,char*argv[]){Matframe;Matback;Matfront;vector>hand_middle;VideoCapturecap(0);BackgroundSubtractorMOG2bg;

c++ - 有没有比 allocator_type 更好的方法来区分可调整大小的容器?

我有operator>>()的模板重载,我需要区分可以调整大小的容器(例如vector)和不能调整大小的容器(例如,数组。我目前只是在使用allocator_type特征(见下面的代码)——它工作得很好——但想知道是否有更明确的测试方法。templatestructis_resizable{typedefuint8_tyes;typedefuint16_tno;templatestaticyestest(classU::allocator_type*);templatestaticnotest(...);staticconstboolvalue=sizeoftest(0)==sizeo

c++ - "unresolved overloaded function type"在 std::function 中有静态函数

尝试将重载静态函数传递给std::function时出现“未解析的重载函数类型”错误。我知道类似的问题,例如this和this.然而,即使那里的答案可以将正确函数的地址放入函数指针中,它们也会因std::function而失败。这是我的MWE:#include#include#includestructClassA{staticstd::stringDoCompress(conststd::string&s){returns;}staticstd::stringDoCompress(constchar*c,size_ts){returnstd::string(c,s);}};voidh

c++ - "gets() was not declared in this scope"错误

这个问题在这里已经有了答案:whyg++shows"gets()"notdeclared,evenafterincluding(3个答案)关闭2年前。使用以下代码,我得到“gets()未在此范围内声明”错误:#include#includeusingnamespacestd;intmain(){//stringstr[]={"Iamaboy"};stringstr[20];`gets(str);cout

c++ - C++ "type deduction"和 Haskell "type inference"有什么区别?

在英语语义中,“typededuction”等于“typeinferring”吗?我不确定这只是不同语言设计者选择的成语偏好,或者计算机科学给出了严格的“类型推导”定义,哪个不是“类型推断”?谢谢。 最佳答案 C++规范和工作草案广泛使用“类型推导”来指代没有类型声明作为引用的表达式类型;例如thisworkingdraftonconcepts在谈论auto声明的变量时使用它,我记得很多书在谈论模板时都使用它,那时候我不得不学习——然后忘记了大部分——C++。Typeinference但是,它有自己的维基百科页面,也是编程语言理论中

c++ - 如何在 C++ 中为不同的迭代器 value_types 重载函数

我想在C++11中实现一个带有一对迭代器的模板函数。如果传递了一对迭代器,其值类型是任意类型的std::pair,则实现应该做一些特殊处理。我试图提出以下定义://arbitraryvaluetypestemplatevoidprocess(Iterbegin,Iterend){for(Iteriter=begin;iter!=end;++iter){std::cout::value_type,std::pair>::value>::type*=0>voidprocess(Iterbegin,Iterend){for(Iteriter=begin;iter!=end;++iter){s

c++ - `type *var = (int)0` ,合法与否?

下面的例子:char*var=(int)0;在gcc和cl.exe上编译,但在clang中导致错误:cannotinitializeavariableoftype'char*'withanrvalueoftype'int'谁是正确的?对于它的值(value),C++11说(强调我的)4.10/1Anullpointerconstantisanintegralconstantexpression(5.19)prvalueofintegertypethatevaluatestozerooraprvalueoftypestd::nullptr_t.Anullpointerconstantca

c++ - init-declarators 的完整表达式的定义

在init-declarator的情况下完整表达式的定义据说“包括”初始化程序的组成表达式,以及应用的任何转换/隐式调用的函数(构造函数)。这意味着完整表达式甚至不需要是表达式,这没有意义,因为它被称为一个(初始化声明符不是表达式)。进一步在标准中,完整的表达式被用作表达式,那么如果它可以包含不相交的表达式,甚至不是表达式的东西,那有什么意义呢?无论如何,我的主要问题是为什么不总是表达式的完整表达式被视为表达式?这应该如何运作? 最佳答案 Thismeansthatafull-expressionneednotevenbeanexp

c++ - #include <string> 在 header 中定义了一些结构。错误 : string does not define a type

#ifndefSTRCUTS_H#defineSTRCUTS_H#includestructmenuEntry{stringitemID;//'string'doesnotnameatypestringitemName;//'string'doesnotnameatype};#endif当我将#include放在header保护上方时,我得到了同样的错误。想一想,我以前在将结构定义放在标题中时遇到过奇怪的麻烦。一定是我没有得到的东西。 最佳答案 您需要将string更改为std::string,即#ifndefSTRCUTS_H#d

C++ 错误 : invalid types 'int[int]' for array subscript

尝试学习C++并完成一个关于数组的简单练习。基本上,我已经创建了一个多维数组,我想创建一个打印出值的函数。Main()中的注释for循环工作正常,但是当我尝试将该for循环转换为函数时,它不起作用,而且对于我来说,我不明白为什么。#includeusingnamespacestd;voidprintArray(inttheArray[],intnumberOfRows,intnumberOfColumns);intmain(){intsally[2][3]={{2,3,4},{8,9,10}};printArray(sally,2,3);//for(introws=0;rows