Same-Named Variables

#include <iostream>
using namespace std;

namespace A { int threshold = 50; }

namespace B { int threshold = 75; }

int main() {
    cout << "A.threshold=" << A::threshold << "\n";
    cout << "B.threshold=" << B::threshold << "\n";
    return 0;
}

Namespaces resolved at compile time(no overhead)

 

 

 

 

 

Upvote
Downvote
Loading...

Input

Expected Output

A.threshold=50 B.threshold=75