草庐IT

declare_namespace

全部标签

c++ - 错误 : ambiguates old declaration ‘double round(double)’

/usr/include/i386-linux-gnu/bits/mathcalls.h:311:1:error:ambiguatesolddeclaration‘doubleround(double)’g.cpp:Infunction‘intround(double)’:g.cpp:14:24:error:newdeclaration‘intround(double)’/usr/include/i386-linux-gnu/bits/mathcalls.h:311:1:error:ambiguatesolddeclaration‘doubleround(double)’#includ

c++ - 在 C++ 中 : why does a constructor get called when an array of objects is declared?

MyClassmc2[]={MyClass(),MyClass()};//thiscallstheconstructortwiceMyClassmc1[4];//thiscallstheconstructor4times.Why?所以,我的问题是:为什么没有初始化的对象数组声明会导致调用默认构造函数? 最佳答案 在C++中,大小为4的MyClass数组是四个实际对象。它有点像包含该类型的四个成员的结构,当然您可以使用不同的语法访问这些成员,并且存在其他技术差异。因此,定义该数组导致构建4个对象的原因(并且在大致相同的情况下)与定义该

C++ 错误 : definition of implicitly-declared

我正在用C++编写这个链表程序当我测试程序时,我得到了错误linkedlist.cpp:5:24:error:definitionofimplicitly-declared'constexprLinkedList::LinkedList()'LinkedList::LinkedList(){这是代码链表.h文件:#include"node.h"usingnamespacestd;classLinkedList{Node*head=nullptr;intlength=0;public:voidadd(int);boolremove(int);intfind(int);intcount(i

c++ - C++模板函数中,依赖函数调用为什么报 "not declared"错误?

在C++模板函数foo()中,调用::bar(TT*)在gcc4.4.3下会出现以下错误:g++-ohello.o-c-ghello.cpphello.cpp:Infunction'voidfoo(std::vector>&)':hello.cpp:8:error:'::bar'hasnotbeendeclared这是有问题的代码://hello.cpp#includetemplatevoidfoo(std::vector&vec){TT*tt;::bar(tt);vec.push_back(tt);}classBlah{};voidbar(Blah*&){}intmain(intar

c++ - 对于 WIN32 API 引入的预处理器 namespace 污染,是否有简单的一次性解决方案?

众所周知,包括通过为每个Win32API函数设置一个预处理器#define来污染C++中的所有命名空间,该函数可以采用多字节或UTF-16输入。一个例子是:#ifdefUNICODE#defineCreateFontCreateFontW#else#defineCreateFontCreateFontA#endif我已经使用nativeWin32API好几年了,但我快要放弃了!在任何不平凡的项目中,名称冲突足以让您脸色发青。拜托,哦,有人能想出一个解决方案,不需要我在事后根据具体情况#undef这样定义宏吗?我想在这导致任何问题之前采取平权行动错误。而且我一直使用Unicode/UTF

C++ namespace 混淆 - std::vs::vs 调用 tolower 时没有前缀?

这是为什么?transform(theWord.begin(),theWord.end(),theWord.begin(),std::tolower);-不起作用transform(theWord.begin(),theWord.end(),theWord.begin(),tolower);-不起作用但是transform(theWord.begin(),theWord.end(),theWord.begin(),::tolower);-有效theWord是一个字符串。我正在usingnamespacestd;为什么它使用前缀::而不是使用std::或什么都不使用?感谢您的帮助。

c++ - 错误 C2248 : 'std::basic_ios<_Elem,_Traits>::basic_ios' : cannot access private member declared in class 'std::basic_ios<_Elem,_Traits>'

我无法理解这个错误。这个错误不在我正在调试的类中。(是吗?)错误是:c:\programfiles\microsoftvisualstudio10.0\vc\include\fstream(890):errorC2248:'std::basic_ios::basic_ios':cannotaccessprivatememberdeclaredinclass'std::basic_ios'1>with1>[1>_Elem=char,1>_Traits=std::char_traits1>]1>c:\programfiles\microsoftvisualstudio10.0\vc\inc

c++ - 可以包装或合并单独的 namespace 吗?

我似乎记得在某处看到有关将多个命名空间合并为一个方法的注释。现在,寻找所说的笔记我没有找到它们——即使使用搜索词组合、分组、合并和包装进行搜索,我也没有找到任何东西。也许我误解了我之前看到的内容。我没有这方面的具体应用,这只是一种好奇心,有点做作。但是,从两个namespace开始......namespacea{intfunc(){return1;}}namespaceb{intfunc(){return2;}}我一直在寻找语法来简单地将它们包装在另一个名称中——事后——(是的,我知道我可以用嵌套的方式重写它)或者将它们合并到一个新的空间中。但是,我确实发现,如果我添加到其中一个非常

C++11 decltype : How to declare the type that a pointer points to?

我有以下代码:#includeintmain(){int*a=newint(2);std::unique_ptrp(a);}导致这些错误信息:Infileincludedfroma.cpp:1:Infileincludedfrom/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/memory:81:/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/

c++ - GCC 编译错误 : declaration of ‘strlen’ must be available

我的问题是,当我想制作一个下载的库时,我从GCC得到了一些奇怪的编译错误。编译器要求更正的代码似乎是正确的。报错都是这样的:Catalogue.h:96:error:therearenoargumentsto‘strlen’thatdependonatemplateparameter,soadeclarationof‘strlen’mustbeavailable这是第96行附近的代码:GaCatalogueEntry(constchar*name,T*data){if(name){_nameLength=(int)strlen(name);//LINE96//copyname_name