草庐IT

declare_namespace

全部标签

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++ - 错误 : 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++ - 奇怪的 C++ namespace 解析怪癖和 g++ 与 clang++

这个问题在这里已经有了答案:Injectedclassnamecompilerdiscrepancy(3个答案)关闭4年前。这始于观察。我更改了一些看起来有点像这样的代码(编辑:我在这里取出了指定的初始化器,它们也不在原始代码中):structS{enumE{E1,E2}member;}//file1.ccSv1={S::E1};//file2.ccSv2={S::S::E2};请注意file2.cc过度限定了E2。然而,这在g++和clang++中都有效。(编辑2:这个特定VM上的g++是g++-5.4.1,但原始代码已经通过早期和后来的g++版本,加上多个clang版本。)事实上,

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

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

c++ - 在这种情况下,为什么 g++ 和 clang 会破坏 namespace 抽象?

编译:structstr{};namespacea{voidfoo(strs){}}namespaceb{voidfoo(strs){}voidbar(strs){foo(s);}}intmain(int,char**){return0;}但这不是(将结构定义移到命名空间a内)namespacea{structstr{};voidfoo(strs){}}namespaceb{voidfoo(a::strs){}voidbar(a::strs){foo(s);}}intmain(int,char**){return0;}我得到的错误是bad.cpp:Infunction‘voidb::b

c++ - "duplicate data type in declaration"是什么意思?

请看一下这段代码:QListcontainerList;autowasAlreadyMoved=[&containerList](cItem*item)->bool{//contains(item))returntrue;returnfalse;};我在Ubuntu13.04下使用QtCreator2.8.0和Qt5.1.0。我还使用Clang3.2.1作为编译器。上面的代码编译正常(没有错误,没有警告),但是QtCreator用红线在标记的代码行下划线(就像错误一样):如果我将鼠标悬停在它上面,它会显示“声明中的重复数据类型”,我不知道这是什么意思。它是最简单的lambda,我没有发

c++ - "no ' operator++(int) ' declared for postfix '++ ' [-fpermissive]"枚举

这个问题在这里已经有了答案:HowcanIiterateoveranenum?(28个答案)Whycan'tIincrementavariableofanenumeratedtype?(10个答案)关闭9年前。我有枚举enumProgramID{A=0,B=1,C=2,MIN_PROGRAM_ID=A,MAX_PROGRAM_ID=C,}CurrentProgram;现在,我正尝试像这样递增CurrentProgram:CurrentProgram++,但编译器提示:没有为后缀'+声明'operator++(int)'+'[-fpermissive]。我认为有这样一个运算符可以增加“枚

c++ - 错误 : 'ios_base' has not been declared

我正在使用libcurl下载序列化代码并将其打开,但是,我收到一个错误,看起来fstream丢失了,但它包含在内。我环顾四周,但很少发现错误。下面是错误和代码。错过了什么?编译错误输出g++-gtestGetprice2.cpp-otestGetprice2.o-std=gnu++11-lcurltestGetprice2.cpp:Infunction'intgetData()':testGetprice2.cpp:45:56:error:'ios_base'hasnotbeendeclaredtestGetprice2.cpp:45:72:error:'ios_base'hasnot

c++ - 另一个命名空间内的 `using namespace` 范围

这个问题在这里已经有了答案:scopeofusingdeclarationwithinanamespace(5个答案)关闭5年前。我知道我将using指令的范围限制在一个block或一个函数中。然后它将仅适用于该范围。但是如果该block是一个命名空间,它显然适用于同一命名空间的所有block。那是对的吗?至少,以下示例表明:(http://ideone.com/K8dk7E)namespaceN1{structFoo{};}namespaceN2{usingnamespaceN1;Foof;}namespaceN2{Foof2;}intmain(){N2::f2;}我原以为Foof2