gpt4 book ai didi

c++ - VS2013 遇到基类位于未命名命名空间中的问题

转载 作者:搜寻专家 更新时间:2023-10-31 01:02:06 26 4
gpt4 key购买 nike

以下代码可以正常编译并按预期运行:

#include <iostream>

namespace
{
struct Base
{
void print() const { std::cout << "test"; };
};
};

class Derived : public Base
{
};

int main()
{
Derived d;
d.print();
return 0;
}

但是在运行时使用 QuickWatch 查看 d 时,IntelliSense 似乎无法找到基地。

我通过将 Base 放在命名空间而不是未命名空间中解决了这个问题。

这是 Visual Studio 中的错误,还是我遗漏了什么?

最佳答案

匿名命名空间的这个问题在 VC++ 中已经存在一段时间了 - 请参阅 http://msdn.microsoft.com/en-us/library/0888kc6a%28VS.80%29.aspx .来自链接文档:

The native C++ expression evaluator does not support anonymous namespaces.

The only way to watch the symbol test in this example is to use the decorated name:

例如(int*)?test@?A0xccd06570@mars@@3HA(使用示例中给出的命名空间层次结构来说明这一点)。只是使用修饰名?那太方便了!谢谢,微软。

关于c++ - VS2013 遇到基类位于未命名命名空间中的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27810766/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com