草庐IT

implicitly-declared

全部标签

c++ - 不合格的名称查找 : Why local declaration hides declaration from using directive

考虑这段代码:namespaceA{inti=24;}namespaceB{usingnamespaceA;inti=11;intk=i;//findsB::i,noambiguity}和basic.lookup.unqual.2:§6.4.1Unqualifiednamelookup[basic.lookup.unqual]Thedeclarationsfromthenamespacenominatedbyausing-directivebecomevisibleinanamespaceenclosingtheusing-directive;see[namespace.udir].F

c++ - 前向声明的类型和 "non-class type as already been declared as a class type"

我对以下代码有疑问:templatevoidfoo(structbar&b);structbar{};intmain(){}它在GCC上编译成功,但在MSVC(2008)上编译失败并出现以下错误:C2990:“bar”:已声明为类类型的非类类型是代码错误还是MSVC中的错误?如果我在模板定义之前添加structbar;就可以了。 最佳答案 我们有我们的赢家:https://connect.microsoft.com/VisualStudio/feedback/details/668430/forward-declared-type-

c++ - Clang VS VC++ :"error: declaration of ' T'阴影模板参数”

我正在尝试为theclassiccopy&swapidiom编译以下代码在我的Mac上使用clang3.3templateclassnode{private:node*left;node*right;Tvalue;public:friendvoidswap(node&,node&);//otherstuff}然而链接器却报错了。我现在明白我应该将函数声明为模板。但是,如果我按照建议的样式进行操作,则会发生错误here来自MSDN:templateclassArray{T*array;intsize;public:template//...templatefriendArray*comb

c++ - 错误 : variable or field ‘myfunction’ declared void

这个问题在这里已经有了答案:variableorfielddeclaredvoid(6个答案)关闭7年前。在下文中,我没有定义类型doesntexist。voidmyfunction(doesntexistargument){}GCC4.7.2说“error:variableorfield‘myfunction’declaredvoid”我的问题是:编译器在这里指代函数名称为void而不是参数类型是怎么想的?[编辑]在投票之前,请注意这个问题的答案与错误的顺序和-Wfatal-errors停止打印更直接相关的消息有关。这不仅仅是我在尝试一个稍微模糊的编译器消息。

c++ - 为什么编译器说 : 'enable_if' cannot be used to disable this declaration

templateusingEnable_if=typenamestd::enable_if::type;classDegree;templateconstexprinlineboolIs_Degree(){returnstd::is_base_of::value;}classDegree{public:std::size_tinDeg=0;};templateclassVertex:publicSatellite{public:explicitVertex(intnum):n(num){}private:std::size_tn;};templateclassEdge{public:/

c++ - 将代码从 C++03 迁移到 C++11 : should I be cautious about the implicit default move constructor?

我有一个代码库,我想从C++03切换到C++11。据我所知,某些类将通过具有隐式默认移动构造函数(以及随之而来的移动赋值运算符)而从更改中受益。虽然我完全同意(我什至认为这是一件好事),但我有点担心这种隐式构造函数可能对我拥有的某些不可复制类产生的影响。我举的一个例子是一个类,它包装了libiconv的iconv_t句柄以利用RAII。更明确地说,类如下:classiconv_wrapper{public:iconv_wrapper():m_iconv(iconv_open()){}~iconv_wrapper(){iconv_close(m_iconv);}private://Not

c++ - 通过 using-directive 在 using-declaration 中查找名称

根据c++标准,下面的程序是良构还是病构的?namespaceN{inti;}usingnamespaceN;using::i;intmain(){}我用不同的编译器得到不同的结果:Clang(http://melpon.org/wandbox/permlink/c8vl7XbumyyS6vsw):没有错误。GCC(http://melpon.org/wandbox/permlink/immhNeWFCMcCA800):错误:'i'未声明。根据c++标准,这个程序是良构还是病构的?需要对c++标准的引用。我想弄清楚我应该为哪个编译器提交错误。 最佳答案

c++ - 模板 friend 类 : Forward Declaration or. ..?

假设我有一个模板类,我试图将其声明为友元类。我应该转发声明类还是给它自己的模板?例子:templateclassSLinkedList;templateclassSNode{private:Eelem;SNode*next;friendclassSLinkedList;};或者templateclassSNode{private:Eelem;SNode*next;templatefriendclassSLinkedList;}; 最佳答案 您的第一种方法可能就是您想要的。它将使SLinkedListSNode的friend,并且所有

c++ - 这个私有(private)变量 "not declared in this scope"怎么样?

我目前正在尝试学习更多有关C++面向对象设计的知识(熟悉Java),但遇到了一些困难。我试图将这个项目放在一起,以在使用SFML构建图形和音频的游戏中学习这些原则。我有以下两个文件。WorldObject.h#ifndefWORLDOBJECT_H#defineWORLDOBJECT_H#include#include#include"ImageManager.h"classWorldObject{private:sf::Sprite_sprite;voidSetImagePath(std::stringpath);sf::SpriteGetGraphic();};#endif世界对象

c++ - 删除复制构造函数或复制赋值运算符是否算作 "user declared"?

根据thispresentation,如果复制构造函数或复制赋值运算符是“用户声明的”,则不会生成隐式move操作。删除复制构造函数或复制赋值运算符是否算作“用户声明”?structNoCopy{NoCopy(NoCopy&)=delete;NoCopy&operator=(constNoCopy&)=delete;};是否会为NoCopy类生成隐式move操作?还是删除相关复制操作算作“用户声明”,从而抑制隐式move生成?如果可能的话,我更喜欢引用标准相关部分的答案。 最佳答案 根据您演示文稿的幻灯片14,已删除的复制构造函数是