草庐IT

Non-declaration

全部标签

c++ - g++ 认为我的类声明是 "forward declaration"

这个问题在这里已经有了答案:C++staticpolymorphism(CRTP)andusingtypedefsfromderivedclasses(5个答案)关闭3年前。精简到最低限度,这是我要编译的代码:templateclassB{protected:std::vectorv;public:templatevoidadd(Args...args){this->v.emplace_back(std::forward(args)...);}typenameT::Iget(inti){returnthis->v[i];}};classD:publicB{public:typedefs

C++ 仿函数和模板 : error: declaration of 'class List<T>'

我在模板类中有一个嵌套模板,用于名为List::find()的方法。此方法获取一个仿函数作为输入,即:“函数条件”。templateclassList{....templateIteratorfind(Functioncondition)const;....};templatetypenameList::IteratorList::find(Functioncondition)const{List::Iteratorit=this->begin();for(;it!=this->end();++it){if(condition(*it)){break;}}returnit;}错误是:.

c++ - 嵌套类声明 : template vs non-template outer class

我有一个C++模板类,里面有一个嵌套类,比如:templateclassOuter_t{public:classInner;Inneri;};templateclassOuter_t::Inner{public:floatx;};intmain(){Outer_to_t;//3oranyarbitraryinto_t.i.x=1.0;return0;}编译没有任何问题。然而,一旦我声明了一个类似的非模板类,就像这样:classOuter_1{public:classInner;Inneri;};classOuter_1::Inner{public:floatx;};intmain(){

c++推导 "non type pointer to function"类模板参数

考虑一个模板类:templateclassProxy{voidrun(){ReturnTyperet=Fn();//...dosomething...}};//andafunctionsintfn1(){return5;}floatfn2(){return5;}这可以通过使用实例化:Proxyp1;但是显式声明返回值类型似乎是不必要的。我想要实现的是:someProxyInstantationp1;someProxyInstantationp2;不幸的是,我对c++没有任何期望,这似乎是该语言的一个隐藏角落(至少对我而言)。如果我可以从指向函数的指针获取它的类型——类似于:std::t

c++ - 示例 XSD 失败并返回 "error: no declaration found for element X"

尽管我是xml解析领域的新手,但我能够通过xsd创建有效的c++并成功编译和链接,但是编译器优化了(?)离开实例化。所以,从第一步开始,我尝试helloworldxmlexampleatCodeSynthesis.但这失败了:[wally@lenovotowerxml]$makehelloxsdcxxcxx-treehello.xsdg++-c-ohelloschema.ohello.cxxg++-g-ohello-lxerces-chelloschema.ohello.c++[wally@lenovotowerxml]$./hellohello.xml:2:8error:nodecl

c++ - begin() 如何知道要返回哪种返回类型(const 或 non-const)?

这非常有效:listl;list::const_iteratorit;it=l.begin();list::iteratorit2;it2=l.begin();我不明白list是怎么来的“知道”它必须返回iteratorbegin()版本或const_iteratorbegin()const一个。我正在尝试为我的容器(一个trie)实现迭代器,但我遇到了这个问题。难道C++不应该不按返回类型处理差异化(除非使用奇怪的技巧)?这是一些代码和我得到的编译器错误:我的Trie是一个模板化的trie,可以包含任何类型。我有一个Trie::iter非常量迭代器和一个Trie::const_ite

c++ - 'non-virtual interface' 和 'abstract interface' 有什么区别?

我正在用C++实现设计模式,我希望我的类通过组合来利用接口(interface),这让我研究了实现接口(interface)的不同方法。我想澄清一下这个术语的定义。 最佳答案 非虚拟接口(interface)是一个公共(public)成员函数,它不是虚拟的,但通常希望根据可覆盖的虚拟函数来实现:classInterface{public:intcompute(){returncompute_impl();}private:virtualintcompute_impl()=0;protected:virtual~Interface()

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++ - "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++ - 来自 Voronoi 的 Delaunay boost : missing triangle with non-integral point coordinates

遵循这两个资源:BoostbasictutorialSOQuestion我用boost写了一个Delaunay三角剖分。如果点坐标是完整的(我生成了几个随机测试并且我没有观察到错误),它工作正常。但是,如果这些点不是整数,我会发现许多不正确的三角剖分缺少边缘或错误的边缘。例如这张图片是用四舍五入的值构建的并且是正确的(见下面的代码)但是这个图像是用原始值构建的并且是不正确的(见下面的代码)这段代码重现了这两个例子(没有显示)。#includeusingboost::polygon::voronoi_builder;usingboost::polygon::voronoi_diagram