草庐IT

default-namespace

全部标签

c++ - 'default' 作为变量名

在调试一些代码时,我遇到了一个名为default的数组。我认为不允许关键字作为变量名。#include"stdafx.h"#includeintmain(){intdefault=5;printf("%d\n",default);return0;}现在上面的代码可以在VS2008上顺利编译。'default'不是关键字吗?为什么它可以作为变量名?副作用?附注:Infragistics::Win::UltraWinToolbars::ToolbarsCollection有一个同名的属性! 最佳答案 这是一个knownissue在VC+

c++ - 警告 : specialization of template in different namespace

通过以下代码我得到了警告:warning:specializationof‘templatestructstd::iterator_traits’indifferentnamespace[-fpermissive]templateclassstd::iterator_traits{public:typedefWorddifference_type;typedefWordvalue_type;typedefToken_ptrpointer;typedefWord&reference;typedefstd::bidirectional_iterator_tagiterator_catego

c++ - "indirectly declaring a namespace within another namespace"是什么意思?

[basic.link]C++14标准中的第4段:Anunnamednamespaceoranamespacedeclareddirectlyorindirectlywithinanunnamednamespacehasinternallinkage.Allothernamespaceshaveexternallinkage.Anamehavingnamespacescopethathasnotbeengiveninternallinkageabovehasthesamelinkageastheenclosingnamespaceifitisthenameof...上面的“在另一个命名

c++ - 运算符重载决议如何在 namespace 内工作?

我发现C++运算符重载解析的奇怪行为,我自己无法解释。指向描述它的某些资源的指针与答案一样好。我有2个翻译单元。在一个(称为util.cpp/h)中,我声明并定义了两个运算符(我省略了可读性的实际实现,无论如何都会出现问题)://util.h#ifndefGUARD_UTIL#defineGUARD_UTIL#includestd::istream&operator>>(std::istream&is,constchar*str);std::istream&operator>>(std::istream&is,char*str);#endif和://util.cpp#include"u

c++ - 错误 : name followed by '::' must be a class or namespace name

我正在尝试构建我的第一个ATLDLL项目,我在其中使用ADODB。这里的问题是我给每个ADODB类都加了下划线ADODB::_ConnectionPtrspADOConnection;当我将鼠标移到ADODB::_ConnectionPtr上时,我得到namefollowedby'::'mustbeaclassornamespacenamespADOConnection我得到expecteda';'。请问这是什么意思?请问我该如何解决?非常感谢! 最佳答案 编译器无法找到ADODB的声明。确保在编译器提示的翻译单元中包含相关head

c++ - 错误 : no type named 'vector' in namespace 'std'

为什么会这样?error:notypenamed'vector'innamespace'std';didyoumean'hecto'?voidaskForVector(std::vector*vector);#include#includevoidaskForVector(std::vector*vector);intmain(){std::vectorvector;intsize;askForVector(&vector);std::cout>size;vector->resize(size);for(inti=0;i>vector[i];}for(intj:*vector)std:

c++ - 为什么 lexical_cast 要求运算符>>位于匹配的 namespace 中?

这是一个测试用例:#include#includenamespaceN{enumclassalarm_code_t{BLAH};}std::istream&operator>>(std::istream&is,N::alarm_code_t&code){std::stringtmp;is>>tmp;if(tmp=="BLAH")code=N::alarm_code_t::BLAH;elseis.setstate(std::ios::failbit);returnis;}intmain(){autocode=boost::lexical_cast("BLAH");}Boost拒绝转换,声

c++ - 当其他构造函数存在时,为什么 "ctor() = default"会改变行为?

为什么structwrapper{explicitwrapper(void*);wrapper()=default;intv;};intmain(){returnwrapper().v;}//YoushouldrunthisinDebugmode返回0xCCCCCCCC,而structwrapper{wrapper()=default;intv;};intmain(){returnwrapper().v;}和structwrapper{intv;};intmain(){returnwrapper().v;}都返回0? 最佳答案 在值

c++ - 是否应该在头文件中使用 C++ namespace 别名?

是consideredbadpractice在C++header中使用usingnamespace。使用namespacealiasing同样是个坏主意吗?在header中,每个实现文件都应该声明它希望使用的别名?由于header是您倾向于使用完全指定名称的地方(因为我们不在header中使用命名空间),别名会很有用,但当#included时它们仍会通过您的源传播。此处的最佳做法是什么?什么是命名空间别名的范围? 最佳答案 如果您将命名空间别名放入header中,此别名将成为您(公共(public))API的一部分。有时,这种技术用

iphone - 警告 : XXXX has different visibility (default) in YYYY and (hidden) in ZZZZ

我正在尝试制作一个使用OpenCV和另一个C++库的iPhone应用程序。它似乎可以很好地编译和链接。它确实有效。只是我想摆脱这个丑陋的警告:ld:warning:std::vector>::_M_insert_aux(__gnu_cxx::__normal_iterator>>,intconst&)hasdifferentvisibility(default)in/Users/nacho4d/Documents/Projects/iOS/iAR/opencv_device/lib/libcxcore.a(cxdatastructs.o)and(hidden)in/Users/nach