简体   繁体   中英

C++ | Anonymous namespace colliding with namespace std

#include <queue>
using namespace std;

namespace {
   class priority_queue;
}

priority_queue pq;

How can I distinguish between the two priority_queue names? I tried ::priority_queue to get the global one but to no avail.

It is simple, just change

using namespace std;

to

//using namespace std;

Now you have to type std::priority_queue for the standard one and priority_queue or ::priority_queue for the custom one.

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