草庐IT

declare_namespace

全部标签

c++ - 类方法声明中的 decltype : error when used before "referenced" member is declared

考虑followingcode:structtest{autofunc()->decltype(data){}//ERRORintdata;};intmain(){testt;t.func();}它给出了以下错误:main.cpp:2:29:error:'data'wasnotdeclaredinthisscopeautofunc()->decltype(data){}但是,如果我将data放在func()之上,它不会给出任何错误(livecode):structtest{intdata;autofunc()->decltype(data){}};...所以我的问题是,为什么declt

c++引用同级 namespace

给出:namespaceroot{namespaceparent{namespacechildaclasshard_to_get_at{};}}}namespaceroot{namespaceparent{namespacechildb//howdoIreferrefertonamespacechildbrelativetothecurrentnamespace?..::hard_to_get_atinstance_of_childa_class;//psuedosyntax}}}我需要指定命名空间的完整路径吗?有什么解决办法吗? 最佳答案

c++ - Namespace or Class,只封装函数成员哪个更好

那么,假设我有几个函数来处理文件的打开/关闭。创建一个静态声明所有这些函数的类是否更好还是干脆将“public”函数放在命名空间“file”的头文件中,其余的“实现细节”放在.cc文件中?下面是代码示例。命名空间一有点长,因为我想尽可能清楚。谢谢!!类的实现标题:#ifndefFILE_H#defineFILE_H#include#includeinclude"common.h"enumErrorcode{FILE_CANNOT_OPEN,FILE_CANNOT_CLOSE};classfile{public:staticcommon::LinestoLines(std::string

c++ - -O1/2/3 与 -std=c++1y/11/98 - 如果包含 <cmath> 我收到错误 : '_hypot' was not declared in this scope

我刚刚使用mingw-get-setup更新了MinGW而且我无法构建包含的任何内容header如果我使用大于-O0的东西与-std=c++1y.(我也试过c++11和c++98)我收到这样的错误:g++.exe-pedantic-errors-pedantic-Wextra-Wall-std=c++1y-O3-cZ:\Projects\C++\L6\src\events.cpp-oobj\src\events.oInfileincludedfromz:\lander\mingw\lib\gcc\mingw32\4.8.1\include\c++\cmath:44:0,fromZ:\P

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++ "was not declared in this scope"编译错误

C++新手。在我编写的以下程序中出现此错误:g++-oBlobblob.ccblob.cc:Infunction'intnonrecursivecountcells(color(*)[7],int,int)':blob.cc:41:error:'grid'wasnotdeclaredinthisscope代码如下:#includeenumcolor{BACKGROUND,ABNORMAL,TEMPORARY};constintROW_SIZE=7;constintCOL_SIZE=7;intnonrecursivecountcells(color[ROW_SIZE][COL_SIZE]