草庐IT

Namespace

全部标签

c++ - 铿锵虫?命名空间模板类的 friend

以下代码在clang下不编译,但在gcc和VS下编译:templateclassbar;namespaceNS{templateclassfoo{foo(){}templatefriendclassbar;};}templateclassbar{public:bar(){NS::foof;}};intmain(int,char**){barb;return0;}它失败了:main.cpp:20:22:error:callingaprivateconstructorofclass'NS::foo'NS::foof;^main.cpp:8:9:note:implicitlydeclared

c++ - 铿锵虫?命名空间模板类的 friend

以下代码在clang下不编译,但在gcc和VS下编译:templateclassbar;namespaceNS{templateclassfoo{foo(){}templatefriendclassbar;};}templateclassbar{public:bar(){NS::foof;}};intmain(int,char**){barb;return0;}它失败了:main.cpp:20:22:error:callingaprivateconstructorofclass'NS::foo'NS::foof;^main.cpp:8:9:note:implicitlydeclared

c++ - 错误 C2039 : 'memchr' : is not a member of '` global namespace''

自从我在标准头文件中无缘无故地收到此错误以来已经有一段时间了。谷歌搜索带来了许多答案,但没有一个有效。 最佳答案 好的,我自己修好了。这是一个愚蠢的错误!我在一个库项目中有一个名为“String.h”的文件,该文件被header拾取。可能是因为我已将的路径添加为我的测试项目中的附加包含目录(我收到此错误。)希望这对某人有所帮助。 关于c++-错误C2039:'memchr':isnotamemberof'`globalnamespace'',我们在StackOverflow上找到一个类似

c++ - 错误 C2039 : 'memchr' : is not a member of '` global namespace''

自从我在标准头文件中无缘无故地收到此错误以来已经有一段时间了。谷歌搜索带来了许多答案,但没有一个有效。 最佳答案 好的,我自己修好了。这是一个愚蠢的错误!我在一个库项目中有一个名为“String.h”的文件,该文件被header拾取。可能是因为我已将的路径添加为我的测试项目中的附加包含目录(我收到此错误。)希望这对某人有所帮助。 关于c++-错误C2039:'memchr':isnotamemberof'`globalnamespace'',我们在StackOverflow上找到一个类似

c++ - 为什么在 C++ 命名空间周围使用 extern "C"

几天前,我遇到了这段C++代码,虽然我不能粘贴代码本身,但我可以用一些示例代码重现问题。一、文件namespace.h:#includeusingnamespacestd;namespaceuseless{classX{intm_myint;staticX*m_foobar;X*getPrivVal(void);public:intgetMember(void);X*getStaticVal(void);};}接下来,namespace.cpp:#include"namespace.h"extern"C"{namespaceuseless{X*X::m_foobar=NULL;X*X:

c++ - 为什么在 C++ 命名空间周围使用 extern "C"

几天前,我遇到了这段C++代码,虽然我不能粘贴代码本身,但我可以用一些示例代码重现问题。一、文件namespace.h:#includeusingnamespacestd;namespaceuseless{classX{intm_myint;staticX*m_foobar;X*getPrivVal(void);public:intgetMember(void);X*getStaticVal(void);};}接下来,namespace.cpp:#include"namespace.h"extern"C"{namespaceuseless{X*X::m_foobar=NULL;X*X:

c++ - 命名空间 "std"没有成员 "sort"

尝试对整数数组进行排序,经过一番谷歌搜索,发现使用std::sort的解决方案伴随着以下错误:namespace"std"hasnomember"sort"。只是为了消除我没有使用std命名空间的任何疑虑,这是我的标题:#include"stdafx.h"#include#include#include#includeusingnamespacestd; 最佳答案 添加:#include如std::sort()中所述引用页。见UsingstdNamespace,Whyis"usingnamespacestd"consideredba

c++ - 命名空间 "std"没有成员 "sort"

尝试对整数数组进行排序,经过一番谷歌搜索,发现使用std::sort的解决方案伴随着以下错误:namespace"std"hasnomember"sort"。只是为了消除我没有使用std命名空间的任何疑虑,这是我的标题:#include"stdafx.h"#include#include#include#includeusingnamespacestd; 最佳答案 添加:#include如std::sort()中所述引用页。见UsingstdNamespace,Whyis"usingnamespacestd"consideredba

c++ - 最佳实践 : using namespace or reopen namespace?

就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visitthehelpcenter寻求指导。关闭10年前.假设我在头文件中声明了一个函数(或类,没关系),它是命名空间foo的一部分:namespacefoo{voidbar();…}很长一段时间以来,当我在cpp文件中定义函数时,我一直在重新打开命名空间:namespacefoo{voidbar(){doSomething();…}}那是因为我是通过这种方式学习的,并且在我正在从事的项目中使用了它。直到最

c++ - 最佳实践 : using namespace or reopen namespace?

就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visitthehelpcenter寻求指导。关闭10年前.假设我在头文件中声明了一个函数(或类,没关系),它是命名空间foo的一部分:namespacefoo{voidbar();…}很长一段时间以来,当我在cpp文件中定义函数时,我一直在重新打开命名空间:namespacefoo{voidbar(){doSomething();…}}那是因为我是通过这种方式学习的,并且在我正在从事的项目中使用了它。直到最