문제

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?

도움이 되었습니까?

해결책

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

::write();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top