【问题标题】:Is there any name space called "sdds" ? Because I am not able to find out about it anywhere是否有任何名为“sdds”的命名空间?因为我无法在任何地方找到它
【发布时间】:2021-09-13 14:21:55
【问题描述】:

我正在我的代码中尝试 sdds 命名空间,因为它被要求这样做,但这会引发错误消息。

代码如下:

using namespace sdds;

我收到的错误消息已粘贴,

Error (active)  E0725   name must be a namespace name   w1p1    D:\w1p1\vendingmaching.cpp  5   

【问题讨论】:

  • 在定义之前不存在命名空间。我怀疑您应该包含一个或多个定义此namespace sdds 的标头。
  • 你为什么还要尝试使用using namespace sdds;
  • “按要求执行”是什么要求您这样做?它是否告诉您首先包含特定文件?
  • 是的,我被要求创建 sdds 命名空间并用它包围代码!!!....虽然我不明白它以及如何做到这一点

标签: c++ compiler-errors namespaces


【解决方案1】:

c++ 标准库中没有名为sdds 的命名空间。对于 using 指令:

using namespace sdds;

命名空间sdds 必须存在。请注意,任何人都可以创建名称空间并根据需要为其命名。如果您只想在不更改现有代码的情况下消除错误,您可以添加:

 namespace sdds {
 }

但是,我宁愿假设任何要求您“这样做”的人都希望您包含一些标题,其中引入了名为 sdds 的命名空间,或者您在代码中引入了命名空间。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-02-13
    • 2022-01-16
    • 2013-05-19
    • 1970-01-01
    • 2013-09-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多