Resolve UART Namespaces

#include <iostream>
using namespace std;

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

// Create namespace App  with nested namespace UART
namespace App
{
    namespace UART
    {
        void send()
        {
            std::cout << "APP UART" << std::endl; 
        }
    }
}
int main() {
    int mode;
    cin >> mode;

    // Call correct send() function here
    if (mode ==  1)
    {
        Boot::UART::send();
    }
    else if (mode == 2)
    {
        App::UART::send();
    }
    return 0;
}

Solving Approach

 

 

 

 

 

Upvote
Downvote
Loading...

Input

1

Expected Output

BOOT UART