简体   繁体   中英

An example about namespace in C++

namespace A::B {
  class MyClass{};
}

Can anyone tell me why this code does not compile?

Your code uses nested namespaces, which are a C++17 feature. You probably get an error because your compiler doesn't support C++17, or you haven't configured it to understand C++17. The pre-C++17 version of your code would be

namespace A {
namespace B {
    class MyClass {};
}
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM