Resolve UART Namespaces

#include <iostream>
using namespace std;

// Create namespace Boot with nested namespace UART
namespace Boot{
    namespace UART{
        void send(){
            cout << "BOOT UART";
        }
    }
}

namespace App{
    namespace UART{
        void send(){
            cout << "APP UART";
        }
    }
}
// Create namespace App  with nested namespace UART

namespace Boot_send = Boot::UART;
namespace App_send = App::UART;

int main() {
    int mode;
    cin >> mode;

    // Call correct send() function here
    switch(mode){
        case 1:
            Boot_send :: send();
            break;
        case 2:
            App_send ::send();
            break;

    }

    return 0;
}

Solving Approach

 

 

 

 

 

Upvote
Downvote
Loading...

Input

1

Expected Output

BOOT UART