Question

Can I undo a command using?

Example code of what I was thinking:

#include <iostream>
using namespace std;

namespace one {
    void write() {
        cout << "write:one" << endl;
    }
}

namespace two {
    void write() {
        cout << "write:two" << endl;
    }
}

void write() {
    cout << "write:write" << endl;
}

int main() {
    one::write();
    two::write();
    using one::write;
    write();    //And it's called from namespace one witch is correct
                //but now i want to call a global method and how i can do that.
    return 0;
}

I want to switch from calling one to global. Can I do this? If so, how?

Was it helpful?

Solution

You cannot undo a using directive. But you can use a name from the global namespace with ::. For example,

::write();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top